That line looks suspicious to me.
Bernhard Hiller wrote:
Task task = new Task(() => RemoteChannelProvider.Call(_channel => _channel.SetInfraredFocus(_clientName, _focus)));
RemoteChannelProvider doesn't seem to be a built-in class. What's the signature of the
What I suspect is happening is this:
SetInfraredFocus returns a
Call may or may not discard that task;
- Even if it doesn't discard the task, the
new Task constructor definitely discards it - none of the overloads accept a
- The task returned from the client therefore doesn't observe the result of the task returned from the server. It could even complete before the server call has finished.
RemoteChannelProvider.Call method returns the
Task, then you should be able to fix this by replacing the client code with:
public Task SetInfraredFocus(string _clientName, double _focus)
return Task.Run(() => RemoteChannelProvider.Call(_channel => _channel.SetInfraredFocus(_clientName, _focus)));
Task.Run has overloads which accept a
Func<Task>. The task returned from these will not complete until the inner task has completed, and it will propagate any exceptions correctly.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."