User-1540960300 posted
Hi there,
I'm tying to plot some data which I get in the client_MqttMsgPublishReceived event from the M2Mqtt Library. I have programed this first for a desktop application and the threading problem is solved by using the Dispatcher.Invoke as shown in the code
below.
void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
{
string ReceivedMessage = Encoding.UTF8.GetString(e.Message);
Dispatcher.Invoke(delegate
{ // we need this construction because the receiving code in the library and the UI with textbox run on different threads
...
});
I know I can not use the same construction in ASP.NET but after reading a lot of posts related to Multi-Threading and other related to I have not been able to solve my problem.
When I try to acces the chart from the received data event I receive a NullObjectReference. In other case when I try to put the data in some global variable, this data is not accesible from the UI controller.
What I want to do is to refresh the Chart data from the received data event or insert the received data into some global variables to then plot in the Chart.
Do someone know a way to solve this?
Thanks in advance