Hi,

I have a form in main thread. I also use a 2nd thread as datalayer for
dataset <--> SQL Server. I have some controls that binds with the dataset.

When the 2nd thread modifies the dataset, it will trigger events of a
control that binds to the dataset. My question is if the event run on the 2nd
thread or the main thread?

When I step in, I check Me.InvokeRequired and it's True. Does that mean the
event run on the 2nd (background) thread?

Thanks in advance.

Li

Re: multiple threads with a form by Kevin

Kevin
Tue Jul 18 10:22:24 CDT 2006

The event runs on the 2nd thread. A Windows form is a Single-Threaded
Apartment. If you're working with .Net platform 2.0, you might want to check
out the BackgroundWorker component:

http://msdn2.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

Otherwise, here are a few articles that will help even if a BackgroundWorker
is not available:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms06112002.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms08162002.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms08162002.asp

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.


"Li Weng" <wlwlwlwl@newsgroup.nospam> wrote in message
news:947AF9E3-1518-41C2-8385-E8A94A5D90D4@microsoft.com...
> Hi,
>
> I have a form in main thread. I also use a 2nd thread as datalayer for
> dataset <--> SQL Server. I have some controls that binds with the dataset.
>
> When the 2nd thread modifies the dataset, it will trigger events of a
> control that binds to the dataset. My question is if the event run on the
> 2nd
> thread or the main thread?
>
> When I step in, I check Me.InvokeRequired and it's True. Does that mean
> the
> event run on the 2nd (background) thread?
>
> Thanks in advance.
>
> Li
>
>
>



Re: multiple threads with a form by wlwlwlwl

wlwlwlwl
Tue Jul 18 13:45:02 CDT 2006

Thanks a lot! Kevin.

Li


"Kevin Spencer" wrote:

> The event runs on the 2nd thread. A Windows form is a Single-Threaded
> Apartment. If you're working with .Net platform 2.0, you might want to check
> out the BackgroundWorker component:
>
> http://msdn2.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx
>
> Otherwise, here are a few articles that will help even if a BackgroundWorker
> is not available:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms06112002.asp
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms08162002.asp
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms08162002.asp
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Chicken Salad Alchemist
>
> What You Seek Is What You Get.
>
>
> "Li Weng" <wlwlwlwl@newsgroup.nospam> wrote in message
> news:947AF9E3-1518-41C2-8385-E8A94A5D90D4@microsoft.com...
> > Hi,
> >
> > I have a form in main thread. I also use a 2nd thread as datalayer for
> > dataset <--> SQL Server. I have some controls that binds with the dataset.
> >
> > When the 2nd thread modifies the dataset, it will trigger events of a
> > control that binds to the dataset. My question is if the event run on the
> > 2nd
> > thread or the main thread?
> >
> > When I step in, I check Me.InvokeRequired and it's True. Does that mean
> > the
> > event run on the 2nd (background) thread?
> >
> > Thanks in advance.
> >
> > Li
> >
> >
> >
>
>
>