“Which language should I learn?” is a frequent question I get asked by non-coders wanting to learn or ones who haven’t coded in a while. More often than not it’s because they have a great idea for something they want to make, or just want to automate some repetitious tasks. Perhaps, you just got out of high school or college with proficiency in Java or Python and want to make an app. Though they’re viable options, they are not always the best choice. My friend/co-worker would say C++… for everything. What? NO! There is no golden arrow for solving every… Read More
Ever need to perform a unit test on and want to timeout while waiting for an event? Doing a quick google search for, “C# unit test timeout waiting for event” yields interesting mixed results. Here are a few different methods for completing such a task. Method 1 – Task.WhenAny The following uses the System.Threadding.Task.WhenAny method wrapped inside of our async method, WaitUntil(..). Th Method 2 – Synchronous ManualResetEvent Slightly different implementation without the use of Tasks. Method 3 – TaskCompletionSource Method 4 – Task.WhenAny Asyncronyously awaiting Task.WhenAny allows you to provide a delay as you can see below.