本文介绍了什么在asp.net中等效于c#中的this.invoke()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将以下用C#编写的代码转换为Asp.net
这里,一段C#代码
private delegate void DelegateAddToList(string msg);
private DelegateAddToList m_DelegateAddToList;
....
m_DelegateAddToList = new DelegateAddToList(AddToList);
void AddToList(){...}
.....
线程t =新线程(ReceiveThread);
....
I want to convert the following code written in C# to be in Asp.net
Here, a piece of C# code
private delegate void DelegateAddToList(string msg);
private DelegateAddToList m_DelegateAddToList;
....
m_DelegateAddToList = new DelegateAddToList(AddToList);
void AddToList(){...}
.....
Thread t = new Thread(ReceiveThread);
....
private void ReceiveThread()
{
while (true)
{
runThread.WaitOne(Timeout.Infinite);
while (true)
{
try
{
// receive data
string msg = serialPort.ReadLine();
this.Invoke(this.m_DelegateAddToList, new Object[] { "R: " + msg });
}
catch
{
try
{
this.Invoke(this.m_DelegateStop, new Object[] { });
}
catch { }
runThread.Reset();
break;
}
}
}
}
推荐答案
这篇关于什么在asp.net中等效于c#中的this.invoke()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!