本文整理汇总了C#中ShutdownReason类的典型用法代码示例。如果您正苦于以下问题:C# ShutdownReason类的具体用法?C# ShutdownReason怎么用?C# ShutdownReason使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShutdownReason类属于命名空间,在下文中一共展示了ShutdownReason类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Shutdown
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"));
}
示例2: ExitWindows
public static bool ExitWindows(ExitWindows exitWindows, ShutdownReason reason, bool ajustToken)
{
if (ajustToken && !TokenAdjuster.EnablePrivilege("SeShutdownPrivilege", true)) {
return false;
}
return ExitWindowsEx(exitWindows, reason) != 0;
}
示例3: ShutdownParams
/// <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;
}
示例4: Shutdown
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 );
}
示例5: LogOff
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"));
}
}
示例6: Shutdown
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 );
}
示例7: ReportFailure
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();
}
}
示例8: Shutdown
public NestResult Shutdown(ShutdownReason reason)
{
// host shutdown is called by UI thread.
application.Dispatcher.Invoke(() => { application.Shutdown(); });
return NestResult.Success;
}
示例9: ShutdownParams
public ShutdownParams( ShutdownReason reason, TimeSpan delay, bool killProcess, bool restart )
{
Reason = reason;
Delay = delay;
KillProcess = killProcess;
Restart = restart;
}
示例10: DefaultShutdownInput
public DefaultShutdownInput(ShutdownReason reason, Checkpointer checkpointer)
{
_reason = reason;
_checkpointer = checkpointer;
}
示例11: ChannelOnDisconnected
private void ChannelOnDisconnected(IChannel channel, ShutdownReason reason)
{
ChangeTimerState(false);
_sentBatch = false;
FailedQueuedLetters();
ChannelDisconnected(this, reason);
}
示例12: ChannelDisconnected
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});
}
示例13: ShutdownEventArgs
public ShutdownEventArgs(Exception exception) {
Reason = ShutdownReason.Exception;
Exception = exception;
}
示例14: Kernel32_ProcessShuttingDown
static bool Kernel32_ProcessShuttingDown(ShutdownReason sig) {
ShutdownEventArgs args = new ShutdownEventArgs(sig);
RaiseShutdownEvent(args);
return false;
}
示例15: ChannelDisconnecting
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});
}