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
- Frame.cs
- LocationSectionRecord.cs
- ToolStripButton.cs
- RawMouseInputReport.cs
- SystemIcons.cs
- NativeMethods.cs
- BuilderPropertyEntry.cs
- ExceptionUtil.cs
- XmlAnyElementAttribute.cs
- CompositeScriptReferenceEventArgs.cs
- FileNotFoundException.cs
- XmlNamespaceManager.cs
- GetIndexBinder.cs
- WmlPageAdapter.cs
- HMACSHA1.cs
- Camera.cs
- AddInContractAttribute.cs
- DesignerGeometryHelper.cs
- EntityAdapter.cs
- HtmlInputSubmit.cs
- DebugInfoExpression.cs
- RuleProcessor.cs
- UInt16Storage.cs
- SQLMoney.cs
- XmlDataLoader.cs
- OpenTypeLayoutCache.cs
- NumberFunctions.cs
- DocumentXPathNavigator.cs
- HierarchicalDataTemplate.cs
- DPCustomTypeDescriptor.cs
- TimelineClockCollection.cs
- ProgressBarAutomationPeer.cs
- _WinHttpWebProxyDataBuilder.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- CodeCompileUnit.cs
- OrderByBuilder.cs
- SingleKeyFrameCollection.cs
- Geometry3D.cs
- DeleteIndexBinder.cs
- CoreSwitches.cs
- ReferentialConstraint.cs
- NamedPipeAppDomainProtocolHandler.cs
- ListViewEditEventArgs.cs
- SqlEnums.cs
- EdmError.cs
- WebPartConnectionsCancelEventArgs.cs
- TypeInfo.cs
- OneOfConst.cs
- BamlMapTable.cs
- MethodCallConverter.cs
- DataObjectSettingDataEventArgs.cs
- AnimationClockResource.cs
- SymmetricKeyWrap.cs
- CheckBoxPopupAdapter.cs
- UserUseLicenseDictionaryLoader.cs
- NullToBooleanConverter.cs
- ScrollViewerAutomationPeer.cs
- TargetParameterCountException.cs
- Cursor.cs
- WebPartUserCapability.cs
- TemplateBamlRecordReader.cs
- TargetInvocationException.cs
- IResourceProvider.cs
- Sorting.cs
- SmtpDateTime.cs
- ScriptComponentDescriptor.cs
- BehaviorEditorPart.cs
- DataGridViewMethods.cs
- SectionRecord.cs
- GeneralTransform.cs
- NamespaceInfo.cs
- PeerApplication.cs
- NameNode.cs
- FlowSwitch.cs
- BufferedWebEventProvider.cs
- SurrogateDataContract.cs
- DocumentAutomationPeer.cs
- FormViewPagerRow.cs
- OdbcReferenceCollection.cs
- EnterpriseServicesHelper.cs
- DockPattern.cs
- XmlLinkedNode.cs
- CacheMemory.cs
- SqlCommand.cs
- ParseNumbers.cs
- util.cs
- FontDifferentiator.cs
- CacheModeValueSerializer.cs
- LinqDataSource.cs
- FixedDocumentPaginator.cs
- PageRequestManager.cs
- DefaultParameterValueAttribute.cs
- StringReader.cs
- TargetControlTypeAttribute.cs
- SessionStateItemCollection.cs
- Attributes.cs
- NativeActivity.cs
- CacheForPrimitiveTypes.cs
- WindowsFormsSectionHandler.cs
- PassportIdentity.cs