Results 1 to 2 of 2

Thread: ถามเรื่องการสร้าง thread ใน symbian ครับ (C++)

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    15


    พอดีไม่แน่นภาษา C++ ด้วย แต่ลองพยายามเขียนดู

    ลองทำตามตัวอย่างในเว็บแล้ว แต่ก็ไม่่ผ่านตรง method Create

    RThread iThread;
    _LIT(strThreadName,"NewThread");
    iThread.Create(strThreadName,(TThreadFunction)(RunThreadEntryPoint),0x2000,0,0,NULL,EOwnerThread);
    ---------------------------------------------------------------------------------------------------------------------
    TInt CExAppUi::RunThreadEntryPoint(TAny* param)
    --------------------------------------------------------------------------------------------------------------------
    Error แบบนี้ครับ งงมากมาย
    'int (*)(void *)'
    illegal explicit conversion from &#39;<unknown-type>&#39; to
    --------------------------------------------------------------------------------------------------------------------
    iThread.Create(strThreadName,NULL,0x2000,0,0,NULL,EOwnerThread);
    แบบนี้ build ผ่านครับ (แต่ไม่ใส่ address ไป method ที่ให้ thread ทำงานก็ไม่ได้เรื่องสิ)
    ก็ลองไปเรื่อยๆ
    iThread.Create(strThreadName,RunThreadEntryPoint,0x2000,0,0,NULL,EOwnerThread);
    แบบนี้ก็ไม่ผ่าน
    iThread.Create(strThreadName,*RunThreadEntryPoint,0x2000,0,0,NULL,EOwnerThread);
    นี่ก็ไม่ผ่าน
    ก็น่าจะติดตรง paramter ตัวที่สองนี่แหละครับ
    ไม่รู้จะทำไงดี ลองหลายทางแล้ว
    ดูตัวอย่างตามเว็บเค้าก็ผ่านกันง่ายๆนี่นา
    หรือว่าเพราะเป็น class ที่ inherit จาก CAknViewAppUi หว่า แต่ก็ไม่น่าจะเกี่ยวมั้ง

  2. #2


    ต้องออกตัวก่อนว่า ไม่เคยเขียน c++ ใน symbian แต่พอดู code แล้วพอจะตอบให้ได้บ้างละกัน
    Code:
    iThread.Create(strThreadName,RunThreadEntryPoint,0x2000,0,0,NULL,EOwnerThread);
    ใส่แบบนี้ถูกแล้วครับ แต่ที่ผิดคือ
    Code:
    TInt CExAppUi::RunThreadEntryPoint(TAny* param)
    เจ้า RunThreadEntryPoint มันเป็น member function ครับ ไม่สามารถรู้ address ได้ตอน compile เพราะจะถูกสร้างตอน new class เท่านั้น ดังนั้น มันก็ต้อง error เป็นธรรมดาประมาณนี้
    Code:
    iThread.Create(strThreadName, ไม่รู้ตำแหน่ง,0x2000,0,0,NULL,EOwnerThread); <<< มันก็ compile ไม่ผ่าน แหงแซะ
    จากปัญหานี้ มีวิธีแก้ 2 solution (ถ้าคุณโทรมาตอนนี้ เราจะมอบสิทธิพิเศษให้คุณสำหรับ solution ที่ 3 -*- เฮ้ย ไม่ใช่โฆษณา)
    1. RunThreadEntryPoint ให้เขียนเป็น function ธรรมดา ไม่ใช่ member function
    2. เขียนเป็น member function ก็ได้ แต่ต้องทำเป็น static member function
    ผมเองก็บอกได้เท่านี้แหละ เพราะข้อมูลมีให้ผมแค่นี้ ถ้าจะให้ไล่จริงๆ ต้องเอา code ทั้งหมดมา หุหุ (หยุด อย่าขมิบ ส่งโค้ดมาให้หมด)

Similar Threads

  1. Hi everyone (Introduction thread)
    By sanook666 in forum Introduce Yourself & Tell Your Friends
    Replies: 0
    Last Post: 05-09-2009, 09:27 PM
  2. Perl Thread 2
    By lordbsd in forum Perl
    Replies: 0
    Last Post: 16-05-2008, 01:23 PM
  3. Perl Basic Thread
    By lordbsd in forum Perl
    Replies: 0
    Last Post: 15-05-2008, 07:05 PM
  4. Replies: 0
    Last Post: 11-12-2003, 11:43 PM
  5. การเขียนสร้าง Thread บน C++
    By asylu3 in forum C/C++,C#,VC++,MFC,Win32
    Replies: 0
    Last Post: 11-07-2003, 05:58 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •