What is the difference between EventContext.Extract and EventContext.ExtractAsynch in DSS REST AP...

...I using CSharp

What is the difference between EventContext.Extract and EventContext.ExtractAsynch in DSS REST API using Csharp as Extract is taking lot of time even for Single Ric while Extracting Terms and Conditions report.

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    Refer to their signatures, Extract returns IDssEnumerable<ExtractionRow> while ExtractAsync returns Task<IDssEnumerable<ExtractionRow>>.

    public IDssEnumerable<ExtractionRow> Extract(ExtractionRequestBase extractionRequest);      

    public Task<IDssEnumerable<ExtractionRow>> ExtractAsync(ExtractionRequestBase extractionRequest, CancellationToken cancellationToken = null, IProgress<HttpAsyncStatus> progress = null);

    The Extract method is synchronous so the call will be block until the extraction is complete.

    On the other hand, the ExtractAsync method is asynchronous. It will return immediately without blocking. Therefore, the calling thread is free to perform other jobs and the extraction will be performed by another thread in a thread pool.

    To get a result from a task, the Task.Result property can be used. Moreover, Task.IsCompleted property can also be used to verify whether this Task has completed.

    For more information about Task<TResult>, please refer to this MSDN documentation.

Answers