C
Cralis
Hi guys,
I write a small winforms application that reads data from a device via
a comms cable, and displays data in a grid, labels and other controls.
So, I send a query, such a $Param1, and the device returns a value for
Param1, which I then display in either a cell in a grid view, or else
a label.
Problem is, there's a small split second delay while I do the query at
the moment, as I am doing it in the main thread.
I have split my application into layers, so to make the call, I call a
static class method:
public static string GetParametersValue(string ParamName);
That then builds up a string and sends that to the device, and gets a
reply, which it returns to my GUI.
I use BackGround worker threads for a few WebService calls I make,
which work fine. But now.. I need to use background threads for my
calls to my device. That should be fine - my problem is, I don't think
the thread can access the controls on my form. Certain parameter
types (calls) get populated in certain controls. I think I need to
make an 'UpdateControl type method, which is somehow threadsafe (??) -
but how can I make it nice and genertic allowing it to recieve maybe a
value and a control name (?) which the read can call, to safely update
the GUI?
I write a small winforms application that reads data from a device via
a comms cable, and displays data in a grid, labels and other controls.
So, I send a query, such a $Param1, and the device returns a value for
Param1, which I then display in either a cell in a grid view, or else
a label.
Problem is, there's a small split second delay while I do the query at
the moment, as I am doing it in the main thread.
I have split my application into layers, so to make the call, I call a
static class method:
public static string GetParametersValue(string ParamName);
That then builds up a string and sends that to the device, and gets a
reply, which it returns to my GUI.
I use BackGround worker threads for a few WebService calls I make,
which work fine. But now.. I need to use background threads for my
calls to my device. That should be fine - my problem is, I don't think
the thread can access the controls on my form. Certain parameter
types (calls) get populated in certain controls. I think I need to
make an 'UpdateControl type method, which is somehow threadsafe (??) -
but how can I make it nice and genertic allowing it to recieve maybe a
value and a control name (?) which the read can call, to safely update
the GUI?