LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed with multi-threading

I also forgot the UIR header file when I first posted my revised code. For those who don't want to re-create it from the UIR file, here is a new ZIP with the .c, .uir, and .h (uir).
0 Kudos
Message 11 of 16
(1,857 Views)
Dear Cosmo,

thanks for your help and the sample code, i learnt some new stuff there. Good job.

There is just a minor problem which i notice, your confirm popup panel is not modal, which is what i want actually.
in your program, i can just leave the popup panel alone and restart and stop the application..... 😃

That was the main reason why i use PostDeferredCall....


Cheers
AL
0 Kudos
Message 12 of 16
(1,838 Views)
hey AL,
It can be done in atleast 2 different ways. The quickest way is to go back to a PostDeferred...AndWait() setup, and move the code where that should be into a thrf_exeTimeUp(). This will put the popups back into the main thread and give you modality. Even so, if you make this modification to my new code, you still won't need to post a windows message to the main thread because it is idling in RunUserInterface() instead of CmtWaitFor...Completion().

However, it can be done completely without PostDeferred...AndWait() _and_ have modality on the popups if f_execution is rewritten. I'm actually invested in this now--it's becoming a game (sick, I know). I'll post another code snippet on Monday that does what you want purely with thread functions and thread callbacks and has modality.

Orlan
0 Kudos
Message 13 of 16
(1,827 Views)
Dear cosmo,

will be glad for any help on this. Thanks so very much for the time and effort.

Actually i did try using the thread advance initially, but i got a weird error upon execution and problem lies in the msg popup.

see the link: (not too sure how to do the click here stuff)

http://forums.ni.com/ni/board/message?board.id=180&message.id=15822&view=by_threading&page=1

Cheers
AL
0 Kudos
Message 14 of 16
(1,811 Views)
OK AL,
Sorry about the delay, I've been sick :< . I have another sample program that doesn't need: CmtWaitFor...Completion(), PostDeferredCall(), PostDeferredCallToThread(), or PostDeferred...AndWait(). It only uses the main thread, the timer thread, and a worker thread and its callback.

In a nutshell, I allow the f_execution() to quit when the timer fires, when the task completes, or when the task is interrupted. This thread function is followed by its own callback run by the main thread. That was the trick. Now that you are back in the main thread, f_exeTimeUp() can be called to do the modal dialog boxes if necessary. If the user wants to continue waiting, the worker thread and timer threads are both restarted. If the activity was instead stopped by the user, you just don't do dialog boxes. And the cycle continues....Check it out.

Attached is a new .C, and new .UIR and UIR .h files--even though the UIR should not have changed, but I attached them anyway.

Orlan
Message 15 of 16
(1,780 Views)
Dear Cosmo,

thanks a million, i'll go and try it!!!
Sorry to hear that you are sick. Hope you are feeling much better. Take care.

Cheerio
AL
0 Kudos
Message 16 of 16
(1,762 Views)