No.
You're making a COM call and that will do whatever it needs to.
If you're worried about timeouts you should make async calls that you can cancel.
+++ Rick ---
Ok, thanks a lot.
Alex
Hi Rick,
Thanks for suggesting async calls that you can cancel.
After reading about Task classes and the fact that task cancellation involves cooperation between the user delegate and the code that requested the cancellation, I took the following "short cut" which is working so far:
In your SignalRClient code I replaced Server.Start().Wait();
with this.
var task = Task.Run(() =>
{
Server.Start().Wait(2100);
});
bool isCompletedSuccessfully = task.Wait(TimeSpan.FromMilliseconds(2000));
Fox = foxHandler;
return isCompletedSuccessfully;
I'd like to end the program properly, with something like System.Environment.Exit(1);
, but the method must return isCompletedSuccessfully because the calling program needs to know the status.
Thanks again,
Alex
Oh no, no, no! Don't do this please...
The code is absolutely pointless as it will just sit and wait for the async operation to complete. Anytime you .Wait()
or access .Result
you are synchronously waiting for the async operation to complete. IOW, in the code you posted the Task.Run()
isn't asynchronous at all. In fact it's worse than that because it actually uses more resources on a separate thread, switches thread context adds a compile time generated state machine etc... Lots of extra overhead for no gain and no async operation.
wwDotnetBridge
already includes methods you can can to asynchronously call any .NET instance method using InvokeMethodAsync() and there was recently another method added that allows calling .NET Async methods via InvokeTaskMethodAsync().
This provides some background on how Async/Await works in .NET and how it affects FoxPro calling that code:
Calling Async/Await .NET methods with wwDotnetBridge
+++ Rick ---