Click here to Skip to main content
15,886,110 members

Comments by Pawel Wzietek (Top 4 by date)

Pawel Wzietek 15-Feb-22 11:39am View    
The fact that shape is declared inside Form1 only means that private fields of Form1 appear as public to shape, otherwise it doesn't change anything in that you still need an instance reference to access a non-static class variable from a code outside the class. From this perspective, the code of test is in the shape class but outside the Form1 class. Look here for more examples:
https://www.geeksforgeeks.org/nested-classes-in-c-sharp/
Pawel Wzietek 3-Apr-19 2:25am View    
" so long as your code is running something like an event handler, the UI thread cannot process the message pump "

It is still possible to invoke the message pump from inside the handler with "DoEvents()". Of course in this case the handler itself should be made reentrant.
Pawel Wzietek 30-May-18 3:52am View    
Of course it will work, the only problem is that "Read()" will block the thread until the response is received (UI will not respond) this is why we use events. But even without using the DataReceived handler you can make the app more responsive if you set a short timeout and repeat the Read until you get data, something like:

serialport.ReadTimeout=1;
string response = null;
do
Application.DoEvents(); //keep the UI responsive
try
{response = serialport.ReadLine();}
catch (TimeoutException ){}
while (response == null && !abort); //may add an "abort" variable
Pawel Wzietek 12-Sep-17 9:15am View    
"each test step is call one mothod and pass some necessary parameters, all the methods that are invoked are independent of each other and are distributed across different DLLs."

I'm not sure at all I understand the problem, but maybe you just need a generic abstract class with different implementation for each dll? Eg. this is what I'm using in my library to address different interfaces in a uniform way: Multithreaded communication for GPIB/Visa/Serial interfaces[^]

Pawel