Click here to Skip to main content
16,010,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Thread question Pin
achandra00712-Aug-02 10:43
achandra00712-Aug-02 10:43 
GeneralRe: Thread question Pin
Daniel Lohmann12-Aug-02 10:41
Daniel Lohmann12-Aug-02 10:41 
GeneralRe: Thread question Pin
achandra00712-Aug-02 11:11
achandra00712-Aug-02 11:11 
GeneralRe: Thread question Pin
Daniel Lohmann12-Aug-02 12:23
Daniel Lohmann12-Aug-02 12:23 
GeneralRe: Thread question Pin
achandra00712-Aug-02 12:27
achandra00712-Aug-02 12:27 
GeneralRe: Thread question Pin
Wes Jones12-Aug-02 12:05
Wes Jones12-Aug-02 12:05 
GeneralRe: Thread question Pin
achandra00712-Aug-02 12:21
achandra00712-Aug-02 12:21 
GeneralRe: Thread question Pin
Wes Jones12-Aug-02 12:40
Wes Jones12-Aug-02 12:40 
Hi ashish,

Your function shouldn't cast to AfxGetMainWnd(), you should pass the this ptr to AfxGetMainWnd(). Your thread may work now, but that's only because this is probably a dialog based app where CReadIntoSybaseDlg happens to be your main window (AfxGetMainWnd() is returning a ptr to an actual CReadIntoSybaseDlg). You always want to know what parameter you're passing to your thread function, and AfxGetMainWnd isn't going to return a known type if you ever wanted to use this code in another program.
I don't have much experience w/ CDaoDatabase to know what the exact problem might be, but I suspect that maybe you're opening the record set in your worker thread, and moving through the record set in your main thread(or a similar scenario). If that's the case try to ensure that all access to the database related objects are taking place in the same thread because I suspect that CDaoDatabase doesn't like it if you're doing things from multiple threads. It's conceivable that MFC/CDaoDatabase is attaching itself to a CWnd object in your main thread since that's where it's probably being instantiated from. If MFC is attached to a CWnd in your main thread, and your main thread is blocking while waiting for a worker thread to finish something w/ the database, you could see a lockup condition.

Best advice would to be sure to do all your database accessing from the same thread that's using the db objects. Try doing all the processing in your main thread, and then try it again so that all the processing in the worker thread to see if it behaves differently.
Btw, Do you really need a worker thread for what you're trying to do? I use Sybase & I don't find the queries to take that long.
If you're designing your app so that the UI thread displays data when the worker thread signals that data is ready & your accessing the same db objects, & if CDaoDatabase really has an issue w/ being used this way, it's going to cause you to have to do some extra work.

-Wes


Sonork ID 100.14017 wtheronjones
GeneralRe: Thread question Pin
achandra00713-Aug-02 2:52
achandra00713-Aug-02 2:52 
GeneralRe: Thread question Pin
achandra00713-Aug-02 2:58
achandra00713-Aug-02 2:58 
GeneralRe: Thread question Pin
Wes Jones13-Aug-02 5:31
Wes Jones13-Aug-02 5:31 
GeneralRe: Thread question Pin
achandra00713-Aug-02 7:50
achandra00713-Aug-02 7:50 
GeneralMemory dump Pin
Hugo Hallman12-Aug-02 8:09
Hugo Hallman12-Aug-02 8:09 
GeneralRe: Memory dump Pin
PJ Arends12-Aug-02 15:09
professionalPJ Arends12-Aug-02 15:09 
Generalprintf question Pin
Shawn Horton12-Aug-02 8:10
Shawn Horton12-Aug-02 8:10 
GeneralRe: printf question Pin
Tomasz Sowinski12-Aug-02 8:21
Tomasz Sowinski12-Aug-02 8:21 
GeneralRe: printf question Pin
Shawn Horton12-Aug-02 8:39
Shawn Horton12-Aug-02 8:39 
GeneralRe: printf question Pin
Tomasz Sowinski12-Aug-02 8:54
Tomasz Sowinski12-Aug-02 8:54 
GeneralRe: printf question Pin
Shawn Horton12-Aug-02 9:01
Shawn Horton12-Aug-02 9:01 
GeneralRe: printf question Pin
Tomasz Sowinski12-Aug-02 9:09
Tomasz Sowinski12-Aug-02 9:09 
GeneralRe: printf question Pin
Daniel Lohmann12-Aug-02 10:34
Daniel Lohmann12-Aug-02 10:34 
GeneralRe: printf question Pin
Shawn Horton12-Aug-02 10:49
Shawn Horton12-Aug-02 10:49 
GeneralRe: printf question Pin
Daniel Lohmann12-Aug-02 12:28
Daniel Lohmann12-Aug-02 12:28 
GeneralUser breakpoint called from code. Please help! Pin
redeemer12-Aug-02 6:57
redeemer12-Aug-02 6:57 
GeneralRe: User breakpoint called from code. Please help! Pin
Daniel Turini12-Aug-02 7:25
Daniel Turini12-Aug-02 7:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.