我分析是你的方式不对,而不是一个dt.Select()出了问题,如下:
In a simple Windows Forms application (such as the one created by the Visual Studio.NET application wizard), all forms and controls execute on the same thread – the primordial thread used to launch the application by calling Main() – so those forms and controls can freely call each other’s methods.
When a Windows Forms window invokes a call asynchronously (using a delegate) that call executes on a worker thread from the thread pool, not the thread that created the window. The completion callback method is also executed on the worker thread. As a result, the completion callback method should never update the user interface directly because that would be calling a Windows Forms form or control on a different thread from the thread that created it. Similarly, progress reports triggered by the worker thread are not allowed to directly update controls such as a progress bar. In all these cases, you must marshal the call from the worker thread to the user interface thread. This is exactly what the interface ISynchronizeInvoke interface, defined in the System.ComponentModel namespace is designed to do:public interface ISynchronizeInvoke
{
object Invoke(Delegate method,object[] args);
IAsyncResult BeginInvoke(Delegate method,
object[] args);
object EndInvoke(IAsyncResult result);
bool InvokeRequired {get;}
}
In a simple Windows Forms application (such as the one created by the Visual Studio.NET application wizard), all forms and controls execute on the same thread – the primordial thread used to launch the application by calling Main() – so those forms and controls can freely call each other’s methods.
When a Windows Forms window invokes a call asynchronously (using a delegate) that call executes on a worker thread from the thread pool, not the thread that created the window. The completion callback method is also executed on the worker thread. As a result, the completion callback method should never update the user interface directly because that would be calling a Windows Forms form or control on a different thread from the thread that created it. Similarly, progress reports triggered by the worker thread are not allowed to directly update controls such as a progress bar. In all these cases, you must marshal the call from the worker thread to the user interface thread. This is exactly what the interface ISynchronizeInvoke interface, defined in the System.ComponentModel namespace is designed to do:public interface ISynchronizeInvoke
{
object Invoke(Delegate method,object[] args);
IAsyncResult BeginInvoke(Delegate method,
object[] args);
object EndInvoke(IAsyncResult result);
bool InvokeRequired {get;}
}
解决方案 »
- 急求HttpWebRequest 登录网页hotmail源码或者大家一起讨论一下!
- 与表格绑定的DataTable对象,小于表格中的更改行数,怎么回事?!
- c# 鼠标移动一条画好的线,鼠标到了哪里线就跟着到了哪里?
- DataGrid简单问题!分不多了,
- 数据库中表数据加载到DATASET后写入XML,现在怎么恢复回到数据库中?
- DropDownList的问题,与页面刷新有关。
- 用Timer控件刷新listview,怎样可以不闪?
- 如果在类中使用Response Request等方法,在线等
- 关于同一类库里面的控件调用问题
- 刚学习C#不久,用的 head first C# 有些小问题请教一下
- 做winform程序,从哪里引用mshtml.dll?
- 怎样在窗口之间互传信息
For example, imagine a client on thread T1 and an object on thread T2. If the object implements ISynchronizeInvoke, the client on thread T1 can call ISynchronizeInvoke‘s Invoke() on the object. The implementation of Invoke() will block the calling thread (T1), marshal the call to T2, execute the call on T2, marshal the returned values to T1, and return control to the calling client on T1. Invoke() accepts a delegate targeting the method to invoke on T2, and a generic array of objects as parameters. Because the call is marshaled to a different thread from that of the caller, you might want to be able to invoke it asynchronously. This is exactly what the BeginInvoke() and EndInvoke() methods are intended to provide