Bit*_*lue 0 c# multithreading delegates signature
C#中是否有标准委托,我只能用于调用.我是否必须为每个必须调用的新函数签名声明一个新委托?
现在我只有那些签名.但是,如果我可以使用本机委托来获得任何复杂的返回和参数,那将是很好的.
public bool isDone()
{...}
public void doStuff()
{...}
public void doMoreStuff(object o)
{...}
public void doEvenMoreStuff(string str)
{...}
// I'm declaring my "custom" delegates like this:
private delegate bool delegate_bool();
private delegate void delegate_void(string line);
// and calling via
if (InvokeRequired)
Invoke(new delegate_void(doStuff), new object[] { });
else
{...}
Run Code Online (Sandbox Code Playgroud)
if (InvokeRequired)
return Invoke(new Func<bool>(isDone), new object[] { });
else
{...}
if (InvokeRequired)
BeginInvoke(new Action(doStuff), new object[] { });
else
{...}
if (InvokeRequired)
BeginInvoke(new Action<string>(doEvenMoreStuff), new object[] { "hello world" });
else
{...}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
166 次 |
| 最近记录: |