login about faq

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

asked Dec 30 '15 at 03:21

Stefan%20O's gravatar image

Stefan O
173


I know this is confusing, but the event is actually on the ftp object, not the Task object.

ftp.OnTaskCompleted += ....

link

answered Dec 30 '15 at 08:05

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×131
×33
×15
×9

Asked: Dec 30 '15 at 03:21

Seen: 574 times

Last updated: Dec 30 '15 at 08:05

powered by OSQA