Communication in ASP.NET Core

守給你的承諾、 提交于 2019-12-12 06:39:45

问题


Situation:

I need to create some kind of controlling part of the communication over Modbus TCP/IP in my ASP.NET Core project.

Communication is working correctly with Modbus, but I need to read some Modbus addresses pernamently and I need to set them interval. I have such structure for this in db.

I have now singleton called CommunicationRepository, which is such controller for this protocol and have methods to read from the module, write to module, have structure for data from modules, etc. and create CommunicationRunners.

CommunicationRunner is something that can wait to elapse the interval and than fire delegate from CommunicationRepository - which then read specific Modbus address.

Problem: Now it is done by async, which is slowing down everything else - navigating throught the page, responses from web api, etc. Offcourse this problem is recognizable at small intervals (e.g. 10ms).

How can I make this more stable, non-bugging? Do I have to use threading? If, then how exactly?

I would appreciate some code samples.

Thank you and have a look at images.

来源:https://stackoverflow.com/questions/43865493/communication-in-asp-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!