Skip to content

serber/TaskQueueNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tasks queue

Implemets simple tasks queue

Installation

PM> Install-Package TaskQueueNet

Usage

static void Main(string[] args)
{
    IQueueDispatcher queueDispatcher = new QueueDispatcher(new ParallelTaskHandler());
    queueDispatcher.Start();
    //---
    queueDispatcher.Enqueue(new AsyncTask<string>("http://ya.ru", DownloadAction, 3000));
    queueDispatcher.Enqueue(new AsyncTask<string>("http://rambler.ru", DownloadAction));
    queueDispatcher.Enqueue(new AsyncTask<string>("http://mail.ru", DownloadAction));
    //---
    System.Console.ReadKey();
}

private static async Task DownloadAction(string url)
{
    System.Console.WriteLine($"Download started: {url}, Thread: {Thread.CurrentThread.ManagedThreadId}");

    await new HttpClient().GetStringAsync(url);

    System.Console.WriteLine($"Download complete: {url}, Thread: {Thread.CurrentThread.ManagedThreadId}");
}

About

Simple tasks queue

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published