Multithreading VirtualTerminal

0 votes
asked Aug 5, 2011 by tebee (220 points)
edited Aug 8, 2011

Hi, using Terminal Emulation .NET 2.0 and 4.0 and trivial coding: first load ~20KB data with VirtualTerminal.Screen.Write and then retrieve columnar data with VirtualTerminal.Screen.GetRegions. I notice that the function used in this way is slow, around 1 sec to load (write) and it blocks the processing of other threads. I am new to C# so i.e.,

this.Invoke(new ProcessDataDelegate(_terminal.Screen.Write), onePage);

does not change behavior of the function call as it is not bind to a windows control. I am grasping Lambda's but my target is .NET 2.0. Also, I saw there is support for threading with InvokeRequired. What is the suggested solution in case of threading a call to VirtualTerminal?

Thank you

1 Answer

0 votes
answered Aug 8, 2011 by Lukas Matyska (55,470 points)
edited Aug 8, 2011

Unfortunately, the VirtualTerminal class have no asynchronous API yet, so I suggest you to use standard .NET patterns. You can learn it at e.g. Calling Synchronous Methods Asynchronously or Making Asynchronous Method Calls. I found this StackOverflow post also helpful.

In your case the code can look like this:

private delegate void WriteDelegate(string value);

...

WriteDelegate runner = new WriteDelegate(_terminal.Screen.Write);
runner.BeginInvoke(onePage, null, null);

Actually, I recognize in your sample code a part of my code I've sent you earlier. If you send your project to support@rebex.net, I can suggest you a solution specific to your needs.

...