private void HandleActions() {
// If there are any functions in the list, then run
// them all and then clear the list
if (mainThreadActions.Count > 0)
{
// We have started the loop
inLoop = true;
// Ditto the last lock bro'
lock (mutex)
{
foreach (Action action in mainThreadActions)
action();
mainThreadActions.Clear();
}
// We have ended the loop
inLoop = false;
}
// If there are any buffered actions then move them to the main list
if (mainThreadActionsBuffer.Count > 0)
{
mainThreadActions.AddRange(mainThreadActionsBuffer.ToArray());
mainThreadActionsBuffer.Clear();
}
}