控制台线程. [英] Console Threads.

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

问题描述


我正在尝试使Office communicator 2010自动化.在这里,我试图首先登录OCS.然后打个电话.

由于登录是异步过程,因此我必须等待其完成才能进行调用.即使使用MS API登录之前,也有一些方法可以防止线程耗尽.问题是在控制台应用程序中,我像下面这样调用.

Hi,
I am trying to automate office communicator 2010. Here I am trying to sign in to the OCS first. Then make a call.

Since the sign in is asynchronous process I have to wait for it to complete before making a call. Even there are methods for keeping the thread from running out before the sign in complete with the MS API. The issue is In console application I am calling like below.

void main()
{
    // Creating Object of sign in method
    SighIn sign=new signIn();
    sign.SignIn();

    // Creating Object of Make call method
    MakeCall call=new MakeCall();
    call.makeCall();
}



在这里MakeCall甚至会在登录完成之前运行.来自void的每个对象都在单独的线程中运行?我该如何分类?请帮忙.



Here the MakeCall will run even before the sign in is complete. Each object from void is running in seperate thread?? How can I sort this?? Please help.

推荐答案

您可以加入线程,但是,让线程进行工作又有什么意义呢?设置一个事件机制,在该机制中,登录对象将发布一个偶数(表示已完成),并即使在类创建后也进行订阅(在main中).在事件处理程序中,执行MakeCall任务.
You can join the threads, but then, what would be the point of having threads do the work? Set up an event mechanism where the signin object posts an even that indicates that it''s done, and subscribe to that even after the class is created (in main). In your event handler, do the MakeCall stuff.


这篇关于控制台线程.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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