背景工人问题. [英] Backround Worker Issue.

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

问题描述


我是WPF的新手

Internet断开连接期间如何保持后台工作线程保持活动状态?

问候,
Prabu

Hi,
I''m new to WPF

How to maintain background worker thread keep Alive during internet disconnect?

Regards,
Prabu

推荐答案

线程生命周期与Internet连接无关,它一直处于活动状态,直到线程退出其主要方法或中止为止.除非涉及UI,否则它也与WPF无关(请参阅类System.Windows.Threading.Dispatcher).

但是,对于网络通信来说,更好的设计使用一些由其构造函数System.Threading.Thread.Thread创建的永久"线程,请参见在C#和套接字编程中使用api [来自同一端口号的多个客户端 [通过服务器触发的自动更新程序 [
Thread life cycle has nothing to do with internet connection, it is kept alive until the thread exits its main method or is aborted. It also has nothing to do with WPF unless UI is involved (than see the class System.Windows.Threading.Dispatcher).

However, for network communications better design uses some "permanent" thread, created by its constructor System.Threading.Thread.Thread, see http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx[^].

You can find some ideas in my past solutions:
using api in c# and socketprogramming[^],
Multple clients from same port Number[^],
automatic updater triggered via server[^].
If this is not related to your application — sorry, you did not provide any detail.

—SA


这篇关于背景工人问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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