Skip to content

Instantly share code, notes, and snippets.

@tobbbe
Created September 4, 2019 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobbbe/841b193fced11975c8a8d09b8077f27c to your computer and use it in GitHub Desktop.
Save tobbbe/841b193fced11975c8a8d09b8077f27c to your computer and use it in GitHub Desktop.
public class Import
{
private static object ImportLock = new object();
private static DateTime LastImport = DateTime.MinValue;
public static ImportInfo Import()
{
lock (ImportLock)
{
if (DateTime.Now.AddSeconds(-10) < LastImport)
{
return "no import - time lock";
}
LastImport = DateTime.Now;
return "imported";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment