Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Timeout.Net

This class is very easy to use Just add it to your project And then

   using Timeout.Net

1.Create an instance of the TimeoutContext class

    TimeoutContext<string, string> ctx = new TimeoutContext<string, string>();

2.Add Timeout Context Event Handllers

timeout.OnItemScheduled += timeout_OnKeyAdded;
timeout.OnScheduledItemExpired += timeout_OnKeyExpier;





void timeout_OnKeyExpier(string key)
{
    Console.WriteLine($"Key {key} Expierd");
}

void timeout_OnKeyAdded(string key)
{
    Console.WriteLine($"Key {key} Added");
}

Scedule a Key Value

  //this code scedule a string key for 10 seccend
   timeout.SetTimeout("key" , new TimeSpan(hours: 0, 0, 10))

Scedule a Action or Code Example

   TimeoutContext<Action, object> timeout = new TimeoutContext<Action, object>();


timeout.SetTimeout(() =>
{
    Console.WriteLine("10 seccend task timeouted");
}, null, new TimeSpan(hours: 0, 0, 10));

timeout.SetTimeout(() =>
{
    Console.WriteLine("15 seccend task timeouted");
}, null, new TimeSpan(hours: 0, 0, 15));

About

Simple Multi Thread Timeout class library for .net To implement Timeout feature in .Net

Topics

Resources

Stars

5 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages