Skip to content

Instantly share code, notes, and snippets.

@zaccharles
Created January 12, 2019 13:54
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 zaccharles/e6c30b04549719317bd08e7ab5d75814 to your computer and use it in GitHub Desktop.
Save zaccharles/e6c30b04549719317bd08e7ab5d75814 to your computer and use it in GitHub Desktop.
Files survive when your handler doesn't
public class Handler
{
private Guid _variableGuid;
public Handler()
{
_variableGuid = Guid.NewGuid();
Console.WriteLine($"Constructor: {_variableGuid}");
}
public void EntryPoint()
{
Console.WriteLine($"EntryPoint: {_variableGuid}");
const string file = "/tmp/zac";
// Execution #1
if (!File.Exists(file))
{
File.WriteAllText(file, _variableGuid.ToString());
Console.WriteLine($"Created file.");
return;
}
var fileGuid = Guid.Parse(File.ReadAllText(file));
Console.WriteLine($"File: {fileGuid}");
// Execution #2
if (fileGuid == _variableGuid)
{
Console.WriteLine("GUIDs are the same.");
Thread.Sleep(3000);
return;
}
// Execution #3
Console.WriteLine("GUIDs are NOT the same.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment