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
- ErrorHandler.cs
- TreeView.cs
- COM2EnumConverter.cs
- LocalizabilityAttribute.cs
- AsmxEndpointPickerExtension.cs
- ColumnMapCopier.cs
- TextOnlyOutput.cs
- VisualBasicSettingsHandler.cs
- ExpressionPrinter.cs
- HtmlButton.cs
- OracleTransaction.cs
- RequestCachingSection.cs
- XmlSchemaNotation.cs
- ParentQuery.cs
- ScrollableControl.cs
- FamilyTypeface.cs
- FrameworkTextComposition.cs
- UIAgentAsyncParams.cs
- BaseHashHelper.cs
- SystemIPInterfaceProperties.cs
- RenderCapability.cs
- WindowsTitleBar.cs
- DiagnosticsElement.cs
- jithelpers.cs
- Scripts.cs
- FileDialogCustomPlace.cs
- Evaluator.cs
- DataDocumentXPathNavigator.cs
- BaseCAMarshaler.cs
- WmlPageAdapter.cs
- HealthMonitoringSectionHelper.cs
- QilInvoke.cs
- HttpHandlersSection.cs
- ThaiBuddhistCalendar.cs
- ViewCellSlot.cs
- _ProxyChain.cs
- SelfSignedCertificate.cs
- Metadata.cs
- ClientData.cs
- Int16AnimationBase.cs
- DodSequenceMerge.cs
- ZipIOLocalFileHeader.cs
- FaultPropagationRecord.cs
- ZipIOCentralDirectoryBlock.cs
- WindowsGraphics.cs
- SqlRowUpdatingEvent.cs
- ExpressionReplacer.cs
- Code.cs
- MarkupWriter.cs
- XmlTextWriter.cs
- AsyncOperationLifetimeManager.cs
- ByteAnimationUsingKeyFrames.cs
- HMACMD5.cs
- ConfigXmlCDataSection.cs
- SynchronizedDispatch.cs
- ProfessionalColors.cs
- ForeignConstraint.cs
- PageRanges.cs
- RadioButton.cs
- TableCellAutomationPeer.cs
- TrackBar.cs
- VisualStyleTypesAndProperties.cs
- XPathNavigatorKeyComparer.cs
- CryptoProvider.cs
- MissingMemberException.cs
- XmlMembersMapping.cs
- WindowsFormsSectionHandler.cs
- EntityDesignerBuildProvider.cs
- XmlBinaryWriter.cs
- FrameworkElementAutomationPeer.cs
- counter.cs
- FileDialog_Vista.cs
- HighlightVisual.cs
- HttpResponseHeader.cs
- BuildResultCache.cs
- ImpersonationContext.cs
- DataGridViewMethods.cs
- RowUpdatingEventArgs.cs
- SimpleBitVector32.cs
- OleDbRowUpdatedEvent.cs
- RightsManagementEncryptionTransform.cs
- Buffer.cs
- SessionChannels.cs
- CatalogPart.cs
- CurrentChangedEventManager.cs
- documentsequencetextcontainer.cs
- NonSerializedAttribute.cs
- RightsManagementEncryptedStream.cs
- ProfileParameter.cs
- Invariant.cs
- AnnotationHighlightLayer.cs
- ProviderUtil.cs
- SqlCacheDependencyDatabaseCollection.cs
- MDIControlStrip.cs
- FormatException.cs
- DbConnectionPool.cs
- ServiceContractListItem.cs
- GC.cs
- NumberFunctions.cs
- LayoutSettings.cs