在控制台应用程序中调用代理 [英] Invoking Delegate in a Console Application

查看:180
本文介绍了在控制台应用程序中调用代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将WinForm应用程序迁移到控制台应用程序。



在WinForm应用程序中,我有一些类似于:

  this.Invoke(new LogResponseCallback(this.LogResponse),new object [] {allAlarmsJson}); 


private delegate void LogResponseCallback(string text);
private void LogResponse(string response)
{
this._richTextResponse.Text = response +\r\\\
;
}

在处理某个操作后,已经调用了Main Thread。 / p>

我关心的是如何在控制台应用程序中实现相同的异步委托调用。



任何帮助非常感谢。



提前感谢

解决方案

问题我询问Invoke是如何做的,



对于Control.Invoke()的实现好奇


I need to migrate a WinForm Application to a Console Application.

In the WinForm Application, I have something like:

this.Invoke(new LogResponseCallback(this.LogResponse), new object[] { allAlarmsJson });


   private delegate void LogResponseCallback(string text);
    private void LogResponse(string response)
    {
        this._richTextResponse.Text = response + "\r\n";
    }

Seems like Main Thread has been called after the processing of a certain operation.

My concern is how can the same Asynchronous delegate call can be achieved in the Console application.

Any help would be highly appreciated.

Thanks in advance

解决方案

Here is a question I asked about how Invoke does what it does,

Curious about the implementation of Control.Invoke()

这篇关于在控制台应用程序中调用代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆