I have a program that uses the console and GUI for quite important aspects of my program. I presume that these two parts both use the same thread.
The issue is that I'm using a multimeter with an output, and to receive bits of data from it the program sends commands to do it - it uses SCPI, these commands run through the console.
The issue is, whenever I send a command to the multimeter it makes the program become unresponsive until it has received the data back, I know why and I also know how to fix it, but I'm wondering if there is a better way.
Currently I'm changing the default thread that the GUI runs on:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Thread applicationThread = new Thread(() => Application.Run(new Form1()));
applicationThread.SetApartmentState(ApartmentState.STA);
applicationThread.Start();
}
This stops the program becoming unresponsive when I send commands to the meter, but I'm not 100% sure if this will create any other issues I've yet to see?
My questions are:
- Is there a better way to change the thread that the GUI runs on?
- If not, will this method create any issues I've yet to see?
- Could I change the Console thread instead?