Exemplo n.º 1
0
                                                 static async Task MainAsync()
    {
        var job = new BackgroundJob();

        job.ProgressUpdated += Job_ProgressUpdated;
        try {
            await job.Start(cts.Token);
        } catch (OperationCanceledException ex) {
            Console.WriteLine($"The job failed with an error: {ex}");
        }
    }
Exemplo n.º 2
0
    static async Task MainAsync()
    {
        var job      = new BackgroundJob();
        var progress = new Progress <int>(Job_ProgressUpdated);

        try {
            await job.Start(progress);
        } catch (Exception ex) {
            //now your exception is caught
            Console.WriteLine($"The job failed with an error: {ex}");
        }
    }
Exemplo n.º 3
0
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);

            Thread workerThread = new Thread(() =>
            {
                _backgroundJob = new BackgroundJob(_dependencies);
                _backgroundJob.Start().Wait();
            });

            workerThread.Start();
        }