Created
January 12, 2019 13:54
-
-
Save zaccharles/e6c30b04549719317bd08e7ab5d75814 to your computer and use it in GitHub Desktop.
Files survive when your handler doesn't
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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