I'm creating a C# library that will implement an EventHandler that notifies it's listeners when the computer network connection changes, it has two states --connected and not connected.
Given my requirements, I believe I need a global variable in my library that stores the "connected" boolean value and a continual loop that constantly checks for internet connection, comparing the result of that check with my global boolean.
Should I do an async loop method with locking around my global boolean? Is there any set design pattern that I could use? Please point me in the right direction as I'm relatively new to asynchronous patterns and design principles, examples would be helpful.
Note: I'm also potentially restricted to .NET 4.0, so useful things like Task.Delay might not be available.