private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
EventWaitHandle result;
EventWaitHandle.TryOpenExisting(@"Global\FinishedLoading",
EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify, out result);
if (result != null)
eHandle = result;
else
{
var users = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);
var rule = new EventWaitHandleAccessRule(users, EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify,
AccessControlType.Allow);
var security = new EventWaitHandleSecurity();
security.AddAccessRule(rule);
bool created;
eHandle = new EventWaitHandle(false, EventResetMode.AutoReset, @"Global\FinishedLoading", out created, security);
}
Refresh(this,new RoutedEventArgs());
}
}