Question:
Hi, (C#, .Net 4.5.2, Chilkat 9.5.0.55, Ftp2, Ftp2.ConnectAsync())
I'm trying to use the OnTaskCompleted-Event on the Ftp2 class. The Synchronous method (Connect()) works perfectly. Also the async method when using task.Wait(0). But I'd like to us ethe OnTaskCompleted-Event to don't block my thread. My code snippet:
var tcs = new TaskCompletionSource<bool>();
var t1 = ftp.ConnectAsync();
t1.OnTaskCompleted += (sender, args) => {
var t2 = args.Task;
tcs.SetResult(t2.GetResultBool());
};
if (!t1.Run()) {
tcs.SetResult(false);
}
return tcs.Task;
But my Task never finishes because OnTaskCompleted is not invoked.
Thanks in advance
I know this is confusing, but the event is actually on the ftp object, not the Task object.
ftp.OnTaskCompleted += ....