运行独立于程序流程的功能 [英] run a function independent of program flow

查看:107
本文介绍了运行独立于程序流程的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿!

我是编程的新手。我的新程序有4个函数让我们说funcA(),funcB(),funcC()和funcD()。 funcA()用于读取串口。 funcA()不断读取某个设备的状态,状态变为YES funcA()分别调用funcB(),funcC()和funcD()。 funcB(),funcC()和funcD()只需要很少的时间来执行。在此期间,funcA()停止从串行端口读取状态。所以我需要做的是保持funcA()独立于其他函数并继续读取串口并保存缓冲区。我该怎么做??任何帮助表示赞赏...谢谢...

解决方案

嗨Sharath,



作为ThePhantomUpvoter建议调查线程。我也会推荐异步编程或后台工作者。您应该通过阅读以下链接获得有关这些内容的公平知识。根据自己的喜好选择1:



线程化C# [ ^ ]

异步调用同步方法 [ ^ ]

BackgroundWorker类 [ ^ ]



希望这会有所帮助,问候

Pasan

Hey!
I''m newbie to programming. My new program has 4 functions Lets say funcA(),funcB(),funcC() and funcD(). funcA() is used to read serial port. funcA() constantly reads a status of certain device and status becomes YES funcA() calls funcB(),funcC() and funcD() respectively. funcB(),funcC() and funcD() takes little time to get executed. During that period the funcA() stops reading status from serial port. So What i need to do is keep funcA() independent of other functions and keep reading serial port and save it buffer. How can i do it?? Any help is appreciated... THANK YOU...

解决方案

Hi Sharath,

As ThePhantomUpvoter suggested look into threading. I''d recommend Asynchronous programming or Background Workers too. You should be getting a fair knowledge about each of these by reading below links. Pick 1 to your liking :)

Threading C#[^]
Calling Synchronous Methods Asynchronously[^]
BackgroundWorker Class[^]

Hope this helps, regards
Pasan


这篇关于运行独立于程序流程的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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