C#BackgroundWorker [英] C# BackgroundWorker

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

问题描述

嗨。


我是C#的初学者。


在我的应用程序中,我使用BackgroundWorker。
是否有可能在不停止线程的情况下将工作结构传递给工作的backgroundWorker?



谢谢&抱歉我的语言

解决方案

Hello ganmpr,


如果没有更多上下文,这是一个难以回答的问题。 如果您只想在同一台机器上运行的两个应用程序之间传递数据,那么您有几个选项。以下是一些想法。


如果您不必保护邮件,那么您可以随时使用两个应用程序都可以访问的文件夹。 您可以使用文件观察程序在文件创建后立即响应。


如果您想提供更持久的方法,那么您可以使用MSMQ。


如果您希望保持消息安全并使您能够使用配置更改消息传递协议,那么您可以使用WCF。


无论如何,您需要拥有某种形式的合同。 这很可能是具有在两个应用程序中定义的匹配定义的类。 您可以创建两个应用程序引用的类库。 然后将此合约
序列化为有效负载(xml或json格式),发送到另一个应用程序并反序列化为对象。


希望这有助于...


Hi.

I'm a begginer in C#.

In my application I use BackgroundWorker. Is there a possibility pass structure to the working backgroundWorker without stop the thread?

Thanks & sorry for my language

解决方案

Hello ganmpr,

This is a difficult question to answer without more context.  If you are looking to just pass data between two applications running on the same machine then you have several options. Here are some ideas.

If you do not have to secure the messages then you could always just use folders that both applications have access to.  You could use a file watcher to respond to the files as soon as they are created.

If you want to provide a more durable approach then you could use MSMQ.

If you would like to keep the messaging secure and give you the ability to change the messaging protocol with configuration then you could use WCF.

Regardless, you will need to have some form of contract.  This most likely will be a class with a matching definition that is defined in both applications.  You could create a class library that both applications reference.  This contract will then be serialized into a payload (xml or json format), sent to the other application and deserialized into on object.

Hope this helps...


这篇关于C#BackgroundWorker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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