

Private void HandleWebClientDownloadCompleted(object sender, AsyncCompletedEventArgs e) _currentDownloadRequestor.Tell(new DownloadProgressed(_currentUri, e.ProgressPercentage)) Private void HandleWebClientDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)

We just handle the two callbacks (progress and success).Ī naive approach - that actually works - is the following: private void StartDownload()Ĭlient.DownloadProgressChanged += HandleWebClientDownloadProgressChanged Ĭlient.DownloadFileCompleted += HandleWebClientDownloadCompleted Ĭlient.DownloadFileAsync(_currentUri, _currentTargetPath) Getting progress reporting to work then seemed quite hard. The problem with the PipeTo approach is that our async process gives feedback when it's not done yet too. For an example of using Task inside Actors, check out this example: Akka.NET PipeTo Sample. WebClient.DownloadFileTaskAsync: use the Task Parallell Library.WebClient.DownloadFileAsync: uses callbacks.

There are several ways to make the WebClient do asynchornous downloads: The output of this application should now be: Starting test for Uri ''. TestActor.Tell(new TestActor.StartTest()) Var testActor = system.ActorOf(testProps) Var testProps = Props.Create(() => new TestActor(actor, new Uri(""))) Var props = Props.Create(() => new FileDownloadActor()) Var system = ActorSystem.Create("downloader") We'll define one incoming message RequestDownload and three outgoing messages DownloadStarted, DownloadCompleted and DownloadProgressed: public class FileDownloadActor : ReceiveActor
