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
- TreeBuilder.cs
- SystemWebSectionGroup.cs
- ObjectSecurity.cs
- CompiledRegexRunner.cs
- MessageDroppedTraceRecord.cs
- GraphicsContext.cs
- StringUtil.cs
- SessionSwitchEventArgs.cs
- FlatButtonAppearance.cs
- ImageList.cs
- Highlights.cs
- wmiprovider.cs
- FileVersionInfo.cs
- METAHEADER.cs
- SubclassTypeValidatorAttribute.cs
- KeyGesture.cs
- XmlSchemaSequence.cs
- EntityWithKeyStrategy.cs
- CompositeCollectionView.cs
- ResourceSet.cs
- NameValuePermission.cs
- CqlGenerator.cs
- SecurityTokenProvider.cs
- IpcChannel.cs
- WeakRefEnumerator.cs
- SiteMapPath.cs
- ServicePoint.cs
- ISAPIRuntime.cs
- SourceFilter.cs
- GroupBox.cs
- PolicyValidator.cs
- WebPartZoneCollection.cs
- Span.cs
- SmiRecordBuffer.cs
- DataGridViewComboBoxCell.cs
- XMLUtil.cs
- HtmlShimManager.cs
- XmlUrlResolver.cs
- AppDomainUnloadedException.cs
- SelectionBorderGlyph.cs
- Cursor.cs
- ReadOnlyDictionary.cs
- TypeHelper.cs
- NamespaceInfo.cs
- GCHandleCookieTable.cs
- MenuItem.cs
- WebPartPersonalization.cs
- M3DUtil.cs
- SqlRowUpdatingEvent.cs
- ConsoleCancelEventArgs.cs
- ListenerElementsCollection.cs
- HashSetEqualityComparer.cs
- ParallelSeparator.xaml.cs
- FormViewRow.cs
- BaseContextMenu.cs
- BoundColumn.cs
- CodeTypeParameterCollection.cs
- HitTestWithGeometryDrawingContextWalker.cs
- LeaseManager.cs
- LassoHelper.cs
- WindowsRegion.cs
- XPathAncestorIterator.cs
- MemoryResponseElement.cs
- DragEventArgs.cs
- UriScheme.cs
- StyleCollection.cs
- X509UI.cs
- ButtonColumn.cs
- GridProviderWrapper.cs
- PeerPresenceInfo.cs
- JsonReaderWriterFactory.cs
- WebPartConnectionCollection.cs
- DesignerDataTableBase.cs
- BaseCodePageEncoding.cs
- CodeDOMUtility.cs
- XmlQueryRuntime.cs
- FixedSOMSemanticBox.cs
- TextParagraphCache.cs
- BindingOperations.cs
- EventHandlerService.cs
- XAMLParseException.cs
- ValidatingReaderNodeData.cs
- BaseTypeViewSchema.cs
- WSHttpSecurityElement.cs
- WebPartDisplayModeCollection.cs
- Content.cs
- SqlConnection.cs
- ParserExtension.cs
- OutputCacheSettingsSection.cs
- XmlAttribute.cs
- EventLogInternal.cs
- DelegatingTypeDescriptionProvider.cs
- assertwrapper.cs
- Document.cs
- RotationValidation.cs
- ScriptManager.cs
- InfiniteTimeSpanConverter.cs
- SystemResourceHost.cs
- ToolStripDropDownClosingEventArgs.cs
- Converter.cs