Log in

View Full Version : To bind the message box to application main thread


Swati_Aggarwal
Nov 2, 2009, 04:34 AM
Hi... I have windows application (Asp.net , C#). While performing an activity I display a message box and I want that user should not be able to bypass the messagebox. Until and unless he clicks (YES or NO) he should not be able to perform any operation in application. The problem is that rights I am on a diiferent thread than the main application. So how to attach this new message box to the main application ?

Perito
Nov 5, 2009, 01:49 PM
See if this doesn't help:

Tools for Updating Windows Forms UI from Background Threads (http://www.eggheadcafe.com/tutorials/aspnet/05d5695e-4a33-4308-9734-6b21edabbbc3/tools-for-updating-window.aspx)

Generally, you use a subroutine in the main thread and use Invoke, as shown in the link, to activate it. Put the data to be placed in the main thread in a convenient variable. If there's ever the risk that the variable will be read before it's fully written, you must protect it with a mutex or something similar.

Swati_Aggarwal
Nov 5, 2009, 10:04 PM
Thanks for the reply Perito... It would help.