/// <summary> Creates a ShutdownParams object with given parameters. /// <param name="customReason"/> and <param name="initiatedBy"/> may be null. </summary> public ShutdownParams(ShutdownReason reason, TimeSpan delay, bool restart, [CanBeNull] string customReason, [CanBeNull] Player initiatedBy) : this(reason, delay, restart) { customReasonString = customReason; InitiatedBy = initiatedBy; }
public static void Shutdown(ShutdownReason reasonFlag) { int Result; bool BooleanResult; TokenPrivileges tp = new TokenPrivileges (); long LocallyUniqueIdentifier; IntPtr hproc = (IntPtr)ApiNativeMethods.GetCurrentProcess(); int htok = 0; BooleanResult = ApiNativeMethods.OpenProcessToken( (int)hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok ); if( BooleanResult == false) throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "OpenProcessToken Failed")); tp.Count = 1; tp.LocallyUniqueIdentifier = 0; tp.Attributes = SE_PRIVILEGE_ENABLED; LocallyUniqueIdentifier = 0; BooleanResult = ApiNativeMethods.LookupPrivilegeValue( null, SE_SHUTDOWN_NAME, ref LocallyUniqueIdentifier); if( BooleanResult == false) throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "LookupPrivilegeValue Failed")); tp.LocallyUniqueIdentifier = LocallyUniqueIdentifier; BooleanResult = ApiNativeMethods.AdjustTokenPrivileges( htok, false, ref tp, 0, 0, 0); if( BooleanResult == false) throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "AdjustTokenPrivileges Failed")); Result = User32ApiNativeMethods.ExitWindowsEx(ExitWindows.PowerOff | ExitWindows.Shutdown, reasonFlag); if( Result == 0) throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "Shutdown Failed")); }
public static bool ExitWindows(ExitWindows exitWindows, ShutdownReason reason, bool ajustToken) { if (ajustToken && !TokenAdjuster.EnablePrivilege("SeShutdownPrivilege", true)) { return false; } return ExitWindowsEx(exitWindows, reason) != 0; }
void Shutdown( ShutdownReason reason, bool quit ) { if( shutdownPending ) return; shutdownPending = true; uriDisplay.Enabled = false; console.Enabled = false; console.Text = "Shutting down..."; Server.Shutdown( new ShutdownParams( reason, TimeSpan.Zero, quit, false ), false ); }
public static void LogOff(ShutdownReason reasonFlag) { int Result; Result = User32ApiNativeMethods.ExitWindowsEx(ExitWindows.LogOff, reasonFlag); if( Result == 0) { throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "LogOff Failed")); } }
static void ReportFailure( ShutdownReason reason ) { Console.Title = String.Format( "fCraft {0} {1}", Updater.CurrentRelease.VersionString, reason ); if( useColor ) Console.ForegroundColor = ConsoleColor.Red; Console.Error.WriteLine( "** {0} **", reason ); if( useColor ) Console.ResetColor(); Server.Shutdown( new ShutdownParams( reason, TimeSpan.Zero, false, false ), true ); if( !Server.HasArg( ArgKey.ExitOnCrash ) ) { Console.ReadLine(); } }
void Shutdown( ShutdownReason reason, bool quit ) { if( shutdownPending ) return; //Log( "Shutting down...", LogType.ConsoleOutput ); // write to console only shutdownPending = true; urlDisplay.Enabled = false; console.Enabled = false; Server.Shutdown( new ShutdownParams( reason, 0, quit, false ), false ); }
void Shutdown(ShutdownReason reason, bool quit) { if (shutdownPending) { return; } shutdownPending = true; console.Enabled = false; console.Text = "Shutting down..."; Text = "fCraft " + Updater.CurrentRelease.VersionString + " - shutting down..."; uriDisplay.Enabled = false; if (!startupComplete) { startupThread.Join(); } Server.Shutdown(new ShutdownParams(reason, TimeSpan.Zero, quit, false), false); }
static void ReportFailure(ShutdownReason reason) { Console.Title = String.Format("fCraft {0} {1}", Updater.CurrentRelease.VersionString, reason); if (useColor) { Console.ForegroundColor = ConsoleColor.Red; } Console.Error.WriteLine("** {0} **", reason); if (useColor) { Console.ResetColor(); } Server.Shutdown(new ShutdownParams(reason, TimeSpan.Zero, false, false), true); if (!Server.HasArg(ArgKey.ExitOnCrash)) { Console.ReadLine(); } }
private void LockedShutdown(ShutdownReason reason) { if (!_remoteShutdownRequested) { ChannelDisconnecting?.Invoke(this, reason); } if (reason == ShutdownReason.Requested) { var letter = new Letter.Letter(LetterOptions.Ack) { Type = LetterType.Shutdown }; InternalEnqueue(letter); if (_options.ShutdownGrace.TotalMilliseconds > 0) { Thread.Sleep((int)_options.ShutdownGrace.TotalMilliseconds); } else { Thread.Sleep(10); } } bool wasConnected = IsConnected; _initalizationCount = 0; IsConnected = false; _transmitter?.Stop(); _receiver?.Stop(); DisconnectSocket(); WaitForTranseiviersToShutDown(); FailQueuedLetters(); FailedReceivedLetters(); if (wasConnected) { ChannelDisconnected?.Invoke(this, _remoteShutdownRequested ? ShutdownReason.Remote : reason); } }
private void ChannelDisconnected(IChannel channel, ShutdownReason reason) { Binding binding = channel.Binding; _routeChannels.Remove(channel.RemoteNodeId); if (channel.Direction == Direction.Inbound || reason == ShutdownReason.Requested) { _channels.Remove(binding); UnhookChannel(channel); } Action <IHyperSocket, IDisconnectedEventArgs> evnt = Disconnected; if (evnt != null) { evnt(this, new DisconnectedEventArgs { Binding = binding, Reason = reason, Socket = this, RemoteNodeId = channel.RemoteNodeId }); } }
public static void Shutdown(ShutdownReason reasonFlag) { int Result; bool BooleanResult; TokenPrivileges tp = new TokenPrivileges(); long LocallyUniqueIdentifier; IntPtr hproc = (IntPtr)ApiNativeMethods.GetCurrentProcess(); int htok = 0; BooleanResult = ApiNativeMethods.OpenProcessToken((int)hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok); if (BooleanResult == false) { throw new NolmeGenericException(string.Format(CultureInfo.InvariantCulture, "OpenProcessToken Failed")); } tp.Count = 1; tp.LocallyUniqueIdentifier = 0; tp.Attributes = SE_PRIVILEGE_ENABLED; LocallyUniqueIdentifier = 0; BooleanResult = ApiNativeMethods.LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref LocallyUniqueIdentifier); if (BooleanResult == false) { throw new NolmeGenericException(string.Format(CultureInfo.InvariantCulture, "LookupPrivilegeValue Failed")); } tp.LocallyUniqueIdentifier = LocallyUniqueIdentifier; BooleanResult = ApiNativeMethods.AdjustTokenPrivileges(htok, false, ref tp, 0, 0, 0); if (BooleanResult == false) { throw new NolmeGenericException(string.Format(CultureInfo.InvariantCulture, "AdjustTokenPrivileges Failed")); } Result = User32ApiNativeMethods.ExitWindowsEx(ExitWindows.PowerOff | ExitWindows.Shutdown, reasonFlag); if (Result == 0) { throw new NolmeGenericException(string.Format(CultureInfo.InvariantCulture, "Shutdown Failed")); } }
private static extern int NTSetSystemPowerState(NTSetPowerState_PowerActionFlags powerActionFlags, NTSetPowerState_SystemPowerStateFlags systemPowerStateFlags, ShutdownReason reason);
public ShutdownEventArgs(Exception exception) { Reason = ShutdownReason.Exception; Exception = exception; }
public DefaultShutdownInput(ShutdownReason reason, Checkpointer checkpointer) { _reason = reason; _checkpointer = checkpointer; }
public NestResult Shutdown(ShutdownReason reason) { shutdownLatch.Set(); parameters?.Host.Shutdown(); return(NestResult.Success); }
public static extern bool ExitWindowsEx(ShutdownFlags flags, ShutdownReason reason);
void Shutdown( ShutdownReason reason, bool quit ) { if( shutdownPending ) return; shutdownPending = true; SetURIDisplayEnabled(false); SetConsoleEnabled(false); SetConsoleText("Shutting down..."); Server.Shutdown( new ShutdownParams( reason, TimeSpan.Zero, quit, false ), false ); }
public DisconnectedEventArgs(ShutdownReason shutdownReason) { ShutdownReason = shutdownReason; }
public static extern Boolean ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
public NestResult Shutdown(ShutdownReason reason) { ryu.Get <DaemonService>().Shutdown(); return(NestResult.Success); }
private void ChannelDisconnected(IChannel channel, ShutdownReason reason) { Binding binding = channel.Binding; _routeChannels.Remove(channel.RemoteNodeId); if(channel.Direction == Direction.Inbound || reason == ShutdownReason.Requested) { _channels.Remove(binding); UnhookChannel(channel); } Action<IHyperSocket, IDisconnectedEventArgs> evnt = Disconnected; if(evnt != null) evnt(this, new DisconnectedEventArgs {Binding = binding, Reason = reason, Socket = this, RemoteNodeId = channel.RemoteNodeId}); }
public static extern bool ExitWindowsEx(ExitWindowsFlags uFlags, ShutdownReason dwReason);
private void ChannelOnDisconnected(IChannel channel, ShutdownReason reason) { ChangeTimerState(false); _sentBatch = false; FailedQueuedLetters(); ChannelDisconnected(this, reason); }
public NestResult Shutdown(ShutdownReason reason) { // host shutdown is called by UI thread. application.Dispatcher.Invoke(() => { application.Shutdown(); }); return(NestResult.Success); }
public NestResult Shutdown(ShutdownReason reason) { // host shutdown is called by UI thread. application.Dispatcher.Invoke(() => { application.Shutdown(); }); return NestResult.Success; }
/// <summary> /// Initializes a new instance of the <see cref="ShutdownNotification" /> class. /// </summary> /// <param name="AdditionalInfo">AdditionalInfo.</param> /// <param name="Countdown">Countdown.</param> /// <param name="Reason">Reason.</param> public ShutdownNotification(string AdditionalInfo = default(string), float?Countdown = default(float?), ShutdownReason Reason = default(ShutdownReason)) { this.AdditionalInfo = AdditionalInfo; this.Countdown = Countdown; this.Reason = Reason; }
internal static extern bool ExitWindowsEx(ExitWindows flg, ShutdownReason rea);
public ShutdownParams(ShutdownReason reason, TimeSpan delay, bool restart) { Reason = reason; Delay = delay; Restart = restart; }
private void DispatchAction(Action a) { var initAction = a as InitializeAction; if (initAction != null) { ShardId = initAction.ShardId; _stateMachine.Fire(Trigger.BeginInitialize); return; } var processRecordAction = a as ProcessRecordsAction; if (processRecordAction != null) { Records = processRecordAction.Records; _stateMachine.Fire(Trigger.BeginProcessRecords); return; } var shutdownAction = a as ShutdownAction; if (shutdownAction != null) { ShutdownReason = (ShutdownReason)Enum.Parse(typeof(ShutdownReason), shutdownAction.Reason); _stateMachine.Fire(Trigger.BeginShutdown); return; } var checkpointAction = a as CheckpointAction; if (checkpointAction != null) { CheckpointError = checkpointAction.Error; CheckpointSeqNo = checkpointAction.SequenceNumber; _stateMachine.Fire(Trigger.FinishCheckpoint); return; } throw new MalformedActionException("Received an action which couldn't be understood: " + a.Type); }
static void ReportFailure(ShutdownReason reason) { Console.ForegroundColor = ConsoleColor.Red; Console.Error.WriteLine("** {0} **", reason); Console.Title = String.Format("800Craft {0} {1}", Updater.CurrentRelease.VersionString, reason); Console.ResetColor(); if (!Server.HasArg(ArgKey.ExitOnCrash)) { Console.ReadLine(); } }
/// <summary> /// Handles the event of the dispatcher closing (and disposing) /// because of a disconnect or a user request. /// </summary> /// <param name="reason"> The reason why the dispatcher closed. </param> internal void HandleDispatcherClosed(ShutdownReason reason) { this.ShutdownReason = reason; this.dispatcher = null; #if DEBUG this.runningLock.Set(); #endif this.OnDisconnected(new DisconnectedEventArgs(reason)); }
private void ChannelDisconnecting(IChannel channel, ShutdownReason shutdownReason) { _letterDispatcher.DequeueChannel(channel); Action<IHyperSocket, IDisconnectingEventArgs> evnt = Disconnecting; if(evnt != null) evnt(this, new DisconnectingEventArgs {Binding = channel.Binding, Reason = shutdownReason, RemoteNodeId = channel.RemoteNodeId, Socket = this}); }
public NestResult Shutdown(ShutdownReason reason) { return(NestResult.Success); }
private static extern int InitiateSystemShutdownEx(string lpMachineName, string lpMessage, uint dwTimeout, bool bForceAppsClosed, bool bRebootAfterShutdown, ShutdownReason dwReason);
static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
public static int ExitWindows(ExitWindows exitWindows, ShutdownReason reason) { return(ExitWindowsEx(exitWindows, reason)); }
private void HandleSocketError(ShutdownReason reason) { Receiving = false; if(SocketError != null) SocketError(reason); }
/// <summary> /// /// </summary> /// <param name="message">The message to record</param> /// <param name="timeout">How long to show the shutdown dialog box, in seconds. If zero, there is no prompt and it cannot be aborted easily</param> /// <param name="force">Forcibly close all applications, even if they have unsaved changes</param> /// <param name="reboot">Restart the machine immediately after shutdown</param> /// <param name="reason"></param> /// <returns></returns> public static int InitiateSystemShutdown(string message, uint timeout, bool force, bool reboot, ShutdownReason reason) { return(InitiateSystemShutdownEx(null, message, timeout, force, reboot, reason)); }
public ShutdownEventArgs(ShutdownReason reason) { Reason = reason; Exception = null; }
public NestResult Shutdown(ShutdownReason reason) { trinketDtpServer.Dispose(); host.Shutdown(); return NestResult.Success; }
public void ShutdownAgent(ShutdownReason reason) { ArgUtil.NotNull(reason, nameof(reason)); AgentShutdownReason = reason; _agentShutdownTokenSource.Cancel(); }
private static extern bool ExitWindowsEx(EXIT_WINDOWS uFlags, ShutdownReason dwReason);
private static extern int ExitWindowsEx(ExitWindowsFlags uFlags, ShutdownReason dwReason);
static bool Kernel32_ProcessShuttingDown(ShutdownReason sig) { ShutdownEventArgs args = new ShutdownEventArgs(sig); RaiseShutdownEvent(args); return false; }
public ShutdownParams( ShutdownReason reason, TimeSpan delay, bool killProcess, bool restart ) { Reason = reason; Delay = delay; KillProcess = killProcess; Restart = restart; }
private static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
private static void ShutDown(ShutdownReason downReason) { GemsCraft.fSystem.Server.Shutdown(new ShutdownParams(downReason, TimeSpan.Zero, true, false), true); }
public void ShutdownRunner(ShutdownReason reason) { ArgUtil.NotNull(reason, nameof(reason)); RunnerShutdownReason = reason; _runnerShutdownTokenSource.Cancel(); }
public static extern int ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
void Shutdown(ShutdownReason reason, bool quit) { if (shutdownPending) return; shutdownPending = true; console.Enabled = false; console.Text = "Shutting down..."; Text = "800Craft " + Updater.CurrentRelease.VersionString + " - shutting down..."; uriDisplay.Enabled = false; if (!startupComplete) { startupThread.Join(); } Server.Shutdown(new ShutdownParams(reason, TimeSpan.Zero, quit, false), false); }
internal static extern int ExitWindowsEx (ExitWindows exitFlags, ShutdownReason shutDownReason);
protected virtual void AfterDisconnectHook(ShutdownReason reason) { }
public static extern bool InitiateSystemShutdownEx( string lpMachineName, string lpMessage, uint dwTimeout, bool bForceAppsClosed, bool bRebootAfterShutdown, ShutdownReason dwReason);
/// <summary> Creates a ShutdownParams object with given reason/delay/restart flag. </summary> public ShutdownParams(ShutdownReason reason, TimeSpan delay, bool restart) { Reason = reason; Delay = delay; Restart = restart; }
public NestResult Shutdown(ShutdownReason reason) { trinketDtpServer.Dispose(); host.Shutdown(); return(NestResult.Success); }