Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Thu, 14 Aug 2008 12:56:48 -0700 (PDT),    group: microsoft.public.dotnet.framework.windowsforms        back       


WindowsFormsSynchronizationContext.Send: how does the delegate provided to this method interact with the control's message pump?   
I did look under the hood and this method is calling
Control.Invoke().  Digging deeper down I've stopped at the
RuntimeMethodHandle._InvokeMethodFast() method whose code I cannot
find.

I know that the delegates invoked via Control.BeginInvoke() will use
the window's message pump to send and retrieve the delegate and its
arguments, so the control/form will not react to Windows messages
while it is executing the delegate.  That is the behavior I want to
have as well when the delegate passed to
WindowsFormsSynchronizationContext.Send() executes.

For a bit of a background, I want to have this behavior in order to
make sure that a grid control will not repaint itself while I'm re-
populating the DataTable it is bound to.  If you have other
suggestions on how to ensure that the grid will not read from the
DataTable at the same time a worker thread reloads it, please send
them my way.  We have noticed that the application crashes if a grid
reads from a DataTable at
the same time the worker thread is busy clearing and repopulating it.
The
worker thread runs the queries and then merges the results in the
DataTable the controls are bound to.  It is the merging of the data
only that I want to execute on the UI thread.


Thanks much,  eugen
date: Thu, 14 Aug 2008 12:56:48 -0700 (PDT)   author:   eugen_nw

Re: WindowsFormsSynchronizationContext.Send: how does the delegate provided to this method interact with the control's message pump?   
On Aug 14, 10:56 pm, eugen_nw  wrote:
> I did look under the hood and this method is calling
> Control.Invoke().  Digging deeper down I've stopped at the
> RuntimeMethodHandle._InvokeMethodFast() method whose code I cannot
> find.
>
> I know that the delegates invoked via Control.BeginInvoke() will use
> the window's message pump to send and retrieve the delegate and its
> arguments, so the control/form will not react to Windows messages
> while it is executing the delegate.  That is the behavior I want to
> have as well when the delegate passed to
> WindowsFormsSynchronizationContext.Send() executes.
>
> For a bit of a background, I want to have this behavior in order to
> make sure that a grid control will not repaint itself while I'm re-
> populating the DataTable it is bound to.  If you have other
> suggestions on how to ensure that the grid will not read from the
> DataTable at the same time a worker thread reloads it, please send
> them my way.  We have noticed that the application crashes if a grid
> reads from a DataTable at
> the same time the worker thread is busy clearing and repopulating it.
> The
> worker thread runs the queries and then merges the results in the
> DataTable the controls are bound to.  It is the merging of the data
> only that I want to execute on the UI thread.
>
> Thanks much,  eugen


Hello

Why are you using more then one thread?
Use event

Bast Regarts
Ohav Baumgarten
date: Fri, 15 Aug 2008 02:50:18 -0700 (PDT)   author:   Obaum1

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us