Hi,
I am using background worker for uploading videos with queue.
From the Queuelist I am uploading videos one by one but in background worker dowork event I am calling async await method but event it is not completing the task it is going for background worker completed event.
In the completed event I am deleting completed video and start uploading next one.But dowork method is not awaitable.
Here is my sample code:
void bgWorkerVideoQueue_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (videoQueue != null && videoQueue.Count > 0)
bgWorkerVideoQueue.RunWorkerAsync();
}
async void bgWorkerVideoQueue_DoWork(object sender, DoWorkEventArgs e)
{
if (videoQueue != null && videoQueue.Count > 0)
{
var res = await SaveVideoToServer(videoQueue[0]);
}
}
private async Task<string> SendVideosQueueToServer(string videoName)
{
var tcs = new TaskCompletionSource<string>();
if (videoQueue != null && videoQueue.Count > 0)
{
var res = await SaveVideoToServer(videoName);
tcs.SetResult(res);
//here removing completed video from quelist
}
return await tcs.Task;
}
How can I resolve this issue.
Anybody can help me, is very appreciable.
Thanks in advance.
No comments:
Post a Comment