This project is read-only.

Task.Wait(interval) is not honored

Feb 25, 2016 at 10:27 PM
Hello,

I have the following code in the C# layer:
        public Task<bool> WaitTask(int interval)
        {
            var task = Task.Factory.StartNew((() =>
            {
                var delay = Task.Delay(interval);
                delay.Wait();
                return true;
            }));

            return task;
        }
and this is what the script is:
var promise = csObj.WaitTask(20000);
csObj.Log("--- wait  :");
promise.Wait(5000);
csObj.Log("Result: " + promise.Result);
The code returns only after the Task execution is complete. It does not honor the wait time as in the promise.Wait(5000).

Am I missing something?

Regards,
Prajnan
Marked as answer by PrajnanDas on 2/25/2016 at 3:11 PM
Feb 25, 2016 at 11:12 PM
promise.Result blocks until task is complete.
Feb 26, 2016 at 12:57 AM
Edited Feb 26, 2016 at 1:04 AM
This is not V8.Net related, not sure why you are posting here. That said, try using "await": https://msdn.microsoft.com/en-us/library/hh156528.aspx?f=255&MSPPError=-2147217396

Are you saying that the timeout is not being honoured?