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
- ProgramPublisher.cs
- Encoding.cs
- BypassElementCollection.cs
- ResourceProperty.cs
- SoapExtensionImporter.cs
- UIElement3D.cs
- HttpWebRequest.cs
- HotSpotCollection.cs
- JulianCalendar.cs
- ModuleBuilderData.cs
- SqlException.cs
- ChannelParameterCollection.cs
- DetailsView.cs
- AuthenticationModuleElement.cs
- Set.cs
- DtrList.cs
- Identity.cs
- NetworkCredential.cs
- StreamGeometry.cs
- Label.cs
- FixedPosition.cs
- TreeViewEvent.cs
- TreeNode.cs
- DependencyObjectType.cs
- StringDictionary.cs
- DynamicUpdateCommand.cs
- SqlDependency.cs
- RadioButton.cs
- Margins.cs
- UIElement.cs
- InternalPermissions.cs
- BackgroundFormatInfo.cs
- HybridDictionary.cs
- TCPClient.cs
- MemberDescriptor.cs
- Cursor.cs
- X509KeyIdentifierClauseType.cs
- SoapAttributes.cs
- DataAccessor.cs
- LinkLabelLinkClickedEvent.cs
- Panel.cs
- SystemNetworkInterface.cs
- HtmlLabelAdapter.cs
- InternalControlCollection.cs
- Button.cs
- LocatorGroup.cs
- ProgressBar.cs
- IndexedString.cs
- AuthenticationModuleElementCollection.cs
- NumberFormatInfo.cs
- ListViewGroup.cs
- QuaternionIndependentAnimationStorage.cs
- CodeSpit.cs
- StatusBarDrawItemEvent.cs
- OdbcException.cs
- LinqToSqlWrapper.cs
- DoWhileDesigner.xaml.cs
- FormsAuthenticationUserCollection.cs
- BitHelper.cs
- _DisconnectOverlappedAsyncResult.cs
- Models.cs
- ImportOptions.cs
- TextFormatterImp.cs
- AtomParser.cs
- SafeSystemMetrics.cs
- DataColumnCollection.cs
- WebBrowserNavigatingEventHandler.cs
- WSFederationHttpSecurityMode.cs
- WebPartActionVerb.cs
- ServiceManager.cs
- ListControl.cs
- DataSourceConverter.cs
- ScriptingJsonSerializationSection.cs
- XPathParser.cs
- ResourceContainer.cs
- DbUpdateCommandTree.cs
- XmlNamespaceDeclarationsAttribute.cs
- CompiledAction.cs
- HtmlUtf8RawTextWriter.cs
- AggregateNode.cs
- XmlReflectionMember.cs
- PerformanceCounterPermission.cs
- DateTimeUtil.cs
- DispatcherObject.cs
- EventPropertyMap.cs
- dbdatarecord.cs
- DBNull.cs
- TreeNodeConverter.cs
- ItemMap.cs
- ReadOnlyDictionary.cs
- PartialList.cs
- InvokePattern.cs
- DependencyProperty.cs
- TransformerInfoCollection.cs
- SeparatorAutomationPeer.cs
- WebResponse.cs
- PaintValueEventArgs.cs
- InfoCardConstants.cs
- ActiveXHelper.cs
- DefaultEventAttribute.cs