c#多线程在控制台应用程序中 [英] c# multithreading in console application

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

问题描述

您好,

我想执行以下操作:



1)在后台运行2个线程。

2)一个线程必须接受用户输入并将其传递给另一个线程。

3)当线程1的工作完成然后加注。



我做了第1步和第2步,但没有成功,因为控制台没有打印出任何东西。

如何实现第3步。





谢谢

Hello,
I want to perform the following things:

1) Run 2 threads in background.
2)One thread must take user input and pass it to another thread.
3)When the work of thread 1 is complete then raise.

I did the steps 1 and 2 but unsuccessfully, because the console does not print out any thing.
How to achieve step 3.


Thanks

推荐答案

感谢您的澄清。以某种类型创建一些事件,并在线程完成之前在线程中调用它。如果不知道如何创建和调用事件实例,请首先在MSDN文档中阅读它。只是这样做,如果再次卡住,请显示此代码并通过在此答案中添加注释来询问您的后续问题。



-SA
Thank you for clarification. Create some event in some type and invoke it in the thread before it is complete. If don't know how to create and invoke event instances, first read about it in MSDN documentation. Just do it, and, if you get stuck again, show this code and ask your follow-up questions by adding a comment to this answer.

—SA


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

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