static async Task SilentMain() { var detector = new ApplicationEnumerator(); var apps = (await detector.GetInstalledApplications()).ToList(); if (!apps.Any()) { Trace.TraceWarning("No BitTorrent applications found. Nothing to do, so exiting."); return; } var cancellationSource = new CancellationTokenSource(); // Download the filter var downloader = new FilterDownloader(); var progress = new Progress<ProgressModel>(delegate(ProgressModel model) { Trace.TraceInformation("{0}", model.Caption); }); using (var filter = await downloader.DownloadFilter(null, cancellationSource.Token, progress)) { if (filter.Exception != null) throw filter.Exception; foreach (var application in apps) { Trace.TraceInformation("Updating app {0} {1}", application.Description, application.Version); await application.Application.UpdateFilterAsync(filter, cancellationSource.Token, progress); } } Trace.TraceInformation("Done."); }
public async Task Initialize() { try { telemetryClient = new TelemetryClient(); telemetryClient.InstrumentationKey = "23694f6c-53c2-42e2-9427-b7e02cda9c6f"; telemetryClient.Context.Component.Version = Process.GetCurrentProcess().MainModule.FileVersionInfo.FileVersion; telemetryClient.Context.Session.Id = Guid.NewGuid().ToString(); telemetryClient.Context.Device.OperatingSystem = Environment.OSVersion.ToString(); telemetryClient.TrackPageView("Home"); telemetryClient.Flush(); } catch (Exception ex) { Trace.TraceError("Couldn't initialize telemetry: " + ex); } // Check for updates await CheckForUpdates(); SelectedMirrorProvider = MirrorProviders.First(); apps = (await applicationEnumerator.GetInstalledApplications()).ToList(); if (!apps.Any()) { Trace.TraceWarning("No BitTorrent applications found."); return; } foreach (var result in apps) { Trace.TraceInformation("Found app {0} version {1} at {2}", result.Description, result.Version, result.InstallLocation); } }
static async Task SilentMain() { var detector = new ApplicationEnumerator(); var apps = (await detector.GetInstalledApplications()).ToList(); var cancellationSource = new CancellationTokenSource(); // Download the filter var downloader = new FilterDownloader(); var progressValue = 0; var progress = new Progress <ProgressModel>(delegate(ProgressModel model) { progressValue = model.Value; Trace.TraceInformation("{0}", model.Caption); }); using (var filter = await downloader.DownloadFilter(null, cancellationSource.Token, progress)) { if (filter.Exception != null) { throw filter.Exception; } Trace.TraceInformation("Parsing filter (" + filter.Length + " bytes)"); filter.Stream.Seek(0, SeekOrigin.Begin); using (var reader = new StreamReader(filter.Stream, Encoding.Default, false, 65535, true)) { var line = await reader.ReadLineAsync(); while (line != null) { var entry = DatParser.ParseEntry(line); if (entry != null) { filter.Entries.Add(entry); } var percent = (int)Math.Floor((double)filter.Stream.Position / filter.Stream.Length * 100); await Task.Yield(); //if( percent > progressValue) progress.Report(UpdateState.Decompressing, "Parsed " + filter.Entries.Count + " entries", percent); line = await reader.ReadLineAsync(); } Trace.TraceInformation("Parsed " + filter.Entries.Count + " entries"); } foreach (var application in apps) { Trace.TraceInformation("Updating app {0} {1}", application.Description, application.Version); await application.Application.UpdateFilterAsync(filter, cancellationSource.Token, progress); } } Trace.TraceInformation("Done."); }
public async Task Initialize() { SelectedMirrorProvider = MirrorProviders.First(); apps = (await applicationEnumerator.GetInstalledApplications()).ToList(); if (!apps.Any()) { Trace.TraceWarning("No BitTorrent applications found."); return; } foreach (var result in apps) { Trace.TraceInformation("Found app {0} version {1} at {2}", result.Description, result.Version, result.InstallLocation); } }
public async Task Initialize() { progress = new Progress <ProgressModel>(ProgressHandler); // Check for updates await CheckForUpdates(); SelectedMirrorProvider = MirrorProviders.First(); apps = (await applicationEnumerator.GetInstalledApplications()).ToList(); if (!apps.Any()) { Trace.TraceWarning("No BitTorrent applications found."); return; } foreach (var result in apps) { Trace.TraceInformation("Found app {0} version {1} at {2}", result.Description, result.Version, result.InstallLocation); } }
static async Task SilentMain() { var detector = new ApplicationEnumerator(); var apps = (await detector.GetInstalledApplications()).ToList(); if (!apps.Any()) { Trace.TraceWarning("No BitTorrent applications found. Nothing to do, so exiting."); return; } var cancellationSource = new CancellationTokenSource(); // Download the filter var downloader = new FilterDownloader(); var progress = new Progress <ProgressModel>(delegate(ProgressModel model) { Trace.TraceInformation("{0}", model.Caption); }); using (var filter = await downloader.DownloadFilter(null, cancellationSource.Token, progress)) { if (filter.Exception != null) { throw filter.Exception; } foreach (var application in apps) { Trace.TraceInformation("Updating app {0} {1}", application.Description, application.Version); await application.Application.UpdateFilterAsync(filter, cancellationSource.Token, progress); } } Trace.TraceInformation("Done."); }