In our previous article we described how to create a UiPath custom activity that a robot uses to communicate its progress to a potentially listening application. The chosen communication channel was NamedPipe. In this article we are going to present a sample Windows Form application that could receive the messages sent by the robot and visually present the enclosed information as:
A label’s caption
A progress bar
Like in the previous article for this sample we are also using helper class StreamString from “How to: Use Named Pipes for Network Interprocess Communication”
Issues to be handled:
Application has to be responsive to user interactions (e.g. move, close)
There is no information about the number or frequency of incoming messages we have to wait for connection
So we are going to instantiate the NamedPipe server and asynchronously wait for the connection:
NamedPipeServerStream namedPipeServerStream = new NamedPipeServerStream(“TImpactUiPath”,
When a message is received, in the callback function WaitForConnectionCallBack we end the asynchronous operation to wait for a client to connect and process the message updating in the form:
private void WaitForConnectionCallBack(IAsyncResult result)
StreamString ss = new StreamString(namedPipeServerStream);
string message = ss.ReadString();
After closing the NamedPipe server, the application is not listening anymore for subsequent incoming messages, so we need to instantiate a new server.
When the application is being closed by the user, the asynchronous operation to wait for a client to connect should also be ended and the server closed to release all used resources.
The received message will be a JSON string that can be easily parsed using, for example the Newtonsoft Json.NET library.
Good morning and a Happy New Year to all our readers. T-Impact are back in 2019 with a brand new website and we’re looking forward to lighting the way for more successful digital transformations and robotics implementations across the globe. When developing our new site that our old website never answered one important question. Have you […]
Last week, T-Impact had the pleasure of presenting the LawNet Enterprise Award to Gardner Leader LLP at the 2018 Lawnet Annual Conference and Awards Evening Gala at the Hinckley Island hotel in Leicester.
NOW EXTENDED FOR CYBER MONDAY! Black Friday is always a popular time to shop for technology, but rather than buying an extra coffee machine, why not future-proof your organisation, greatly enhance your survival prospects and begin to reap the benefits of automation across your business? Take advantage of T-Impact’s unique Black Friday offer and get three […]