I am creating a service to manipulate mouse movement and I need my application to be able to communicate with the service to tell it how to move the mouse.
side note, I am doing this in a service because I believe that will also allow it to work on elevated applications as using SendInputs
from a normal desktop app will not work when a elevated app has focus.
I've done some prelim research and seen people say named pipes is the best way to communicate with a service, but will this be able to handle ~500 messages per second (I want the mouse movement to be as fluid as possible)?
I have some basic experience with named pipes but nothing that handles such rapid data.
Below it the basic code that I use in other areas of the application; will this work in the service without needing any modifications? is parsing the data as a string then deserializing my data out of that string the most efficient way to go, in my experience working with string can slow things down at this speed.
NamedPipeServerStream s = new NamedPipeServerStream("MyPipe", PipeDirection.In, 2);
Action<NamedPipeServerStream> a = callBack;
a.BeginInvoke(s, ar => { }, null);
private void callBack(NamedPipeServerStream pipe)
{
while (!SharedProperties.IsClosing)
{
pipe.WaitForConnection();
StreamReader sr = new StreamReader(pipe);
string message = sr.ReadToEnd();
processPipeMessage(message);
pipe.Disconnect();
}
}