Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / ConsoleCancelEventArgs.cs / 1305376 / ConsoleCancelEventArgs.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*==============================================================================
**
** Class: ConsoleCancelEventArgs
**
**
** Purpose: This class provides support goop for hooking Control-C and
** Control-Break, then preventing Control-C from interrupting the
** process.
**
**
=============================================================================*/
namespace System {
using System;
using System.Diagnostics.Contracts;
public delegate void ConsoleCancelEventHandler(Object sender, ConsoleCancelEventArgs e);
[Serializable]
public sealed class ConsoleCancelEventArgs : EventArgs
{
private ConsoleSpecialKey _type;
private bool _cancel; // Whether to cancel the CancelKeyPress event
internal ConsoleCancelEventArgs(ConsoleSpecialKey type)
{
_type = type;
_cancel = false;
}
// Whether to cancel the break event. By setting this to true, the
// Control-C will not kill the process.
public bool Cancel {
get { return _cancel; }
set {
if (SpecialKey == ConsoleSpecialKey.ControlBreak && value == true)
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CantCancelCtrlBreak"));
Contract.EndContractBlock();
_cancel = value;
}
}
public ConsoleSpecialKey SpecialKey {
get { return _type; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*==============================================================================
**
** Class: ConsoleCancelEventArgs
**
**
** Purpose: This class provides support goop for hooking Control-C and
** Control-Break, then preventing Control-C from interrupting the
** process.
**
**
=============================================================================*/
namespace System {
using System;
using System.Diagnostics.Contracts;
public delegate void ConsoleCancelEventHandler(Object sender, ConsoleCancelEventArgs e);
[Serializable]
public sealed class ConsoleCancelEventArgs : EventArgs
{
private ConsoleSpecialKey _type;
private bool _cancel; // Whether to cancel the CancelKeyPress event
internal ConsoleCancelEventArgs(ConsoleSpecialKey type)
{
_type = type;
_cancel = false;
}
// Whether to cancel the break event. By setting this to true, the
// Control-C will not kill the process.
public bool Cancel {
get { return _cancel; }
set {
if (SpecialKey == ConsoleSpecialKey.ControlBreak && value == true)
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CantCancelCtrlBreak"));
Contract.EndContractBlock();
_cancel = value;
}
}
public ConsoleSpecialKey SpecialKey {
get { return _type; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewRowStateChangedEventArgs.cs
- MetabaseServerConfig.cs
- XmlSubtreeReader.cs
- PtsHelper.cs
- EdmProperty.cs
- UriSection.cs
- LazyTextWriterCreator.cs
- XpsThumbnail.cs
- brushes.cs
- SynchronizedDispatch.cs
- AssemblyResourceLoader.cs
- StreamUpgradeAcceptor.cs
- FileFormatException.cs
- SwitchAttribute.cs
- DataKeyArray.cs
- SqlPersonalizationProvider.cs
- TableItemProviderWrapper.cs
- ReadContentAsBinaryHelper.cs
- JsonDataContract.cs
- DataGridViewAccessibleObject.cs
- SmtpNtlmAuthenticationModule.cs
- HttpCookiesSection.cs
- _TransmitFileOverlappedAsyncResult.cs
- MetadataItem_Static.cs
- HwndHost.cs
- CodeConstructor.cs
- PublisherMembershipCondition.cs
- AutomationPeer.cs
- LinqDataSourceEditData.cs
- Mappings.cs
- ActionFrame.cs
- TraceData.cs
- DerivedKeySecurityTokenStub.cs
- Header.cs
- ListenerElementsCollection.cs
- WorkflowOwnershipException.cs
- BinaryReader.cs
- TableRow.cs
- CodeArgumentReferenceExpression.cs
- EventWaitHandleSecurity.cs
- GridToolTip.cs
- QilXmlWriter.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- ServiceOperationDetailViewControl.cs
- ServiceMemoryGates.cs
- EventPrivateKey.cs
- AssemblyCache.cs
- EntityWithKeyStrategy.cs
- ObjectDataSourceMethodEventArgs.cs
- JsonWriterDelegator.cs
- TextTreeTextBlock.cs
- BlurBitmapEffect.cs
- GeneralTransform3D.cs
- FormatConvertedBitmap.cs
- RequestQueue.cs
- ObjectStateManager.cs
- SecurityCriticalDataForSet.cs
- DragDrop.cs
- PassportAuthenticationModule.cs
- SwitchLevelAttribute.cs
- SafeMILHandleMemoryPressure.cs
- CompilerTypeWithParams.cs
- HttpListener.cs
- SharedPersonalizationStateInfo.cs
- Block.cs
- FSWPathEditor.cs
- ProfilePropertyNameValidator.cs
- CompensatableSequenceActivity.cs
- RectangleF.cs
- SqlFileStream.cs
- ECDiffieHellmanCngPublicKey.cs
- StorageScalarPropertyMapping.cs
- UnsafeNativeMethods.cs
- RepeatBehavior.cs
- ZoneButton.cs
- CacheDependency.cs
- TextReader.cs
- ListViewDeletedEventArgs.cs
- ReachDocumentReferenceCollectionSerializer.cs
- BitmapFrame.cs
- PopOutPanel.cs
- ErrorFormatter.cs
- EditorBrowsableAttribute.cs
- PieceNameHelper.cs
- SerTrace.cs
- TextReader.cs
- NameTable.cs
- ExitEventArgs.cs
- EmptyTextWriter.cs
- SettingsPropertyWrongTypeException.cs
- BamlVersionHeader.cs
- ListGeneralPage.cs
- WebServiceEnumData.cs
- OutputCache.cs
- HebrewCalendar.cs
- ISAPIRuntime.cs
- PeerNodeAddress.cs
- FileDialog_Vista.cs
- IMembershipProvider.cs
- MDIControlStrip.cs