Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / fx / src / xsp / System / Web / Util / WorkItem.cs / 1 / WorkItem.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Util { using System.Runtime.InteropServices; using System.Security.Permissions; using System.Threading; // // Support for positing of work items to a different thread // ////// public delegate void WorkItemCallback(); ///[To be supplied.] ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class WorkItem { private static bool _useQueueUserWorkItem = true; private static WaitCallback _onQueueUserWorkItemCompletion = new WaitCallback(OnQueueUserWorkItemCompletion); ///[To be supplied.] ////// [SecurityPermission(SecurityAction.Demand, Unrestricted=true)] public static void Post(WorkItemCallback callback) { #if !FEATURE_PAL // ROTORTODO if (Environment.OSVersion.Platform != PlatformID.Win32NT) throw new PlatformNotSupportedException(SR.GetString(SR.RequiresNT)); #else // !FEATURE_PAL throw new NotImplementedException("ROTORTODO"); #endif // !FEATURE_PAL PostInternal(callback); } // assertt to disregard the user code up the compressed stack [PermissionSet(SecurityAction.Assert, Unrestricted=true)] private static void CallCallbackWithAssert(WorkItemCallback callback) { callback(); } private static void OnQueueUserWorkItemCompletion(Object state) { WorkItemCallback callback = state as WorkItemCallback; if (callback != null) { CallCallbackWithAssert(callback); } } internal static void PostInternal(WorkItemCallback callback) { if (_useQueueUserWorkItem) { ThreadPool.QueueUserWorkItem(_onQueueUserWorkItemCompletion, callback); } else { WrappedWorkItemCallback w = new WrappedWorkItemCallback(callback); w.Post(); } } } internal class WrappedWorkItemCallback { private GCHandle _rootedThis; private WorkItemCallback _originalCallback; private WorkItemCallback _wrapperCallback; internal WrappedWorkItemCallback(WorkItemCallback callback) { _originalCallback = callback; _wrapperCallback = new WorkItemCallback(this.OnCallback); } internal void Post() { _rootedThis = GCHandle.Alloc(this); if (UnsafeNativeMethods.PostThreadPoolWorkItem(_wrapperCallback) != 1) { _rootedThis.Free(); throw new HttpException(SR.GetString(SR.Cannot_post_workitem)); } } private void OnCallback() { _rootedThis.Free(); _originalCallback(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.[To be supplied.] ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ModelPropertyCollectionImpl.cs
- TraceUtility.cs
- ObjectHelper.cs
- ListBindableAttribute.cs
- SendMailErrorEventArgs.cs
- TreePrinter.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- BaseCodeDomTreeGenerator.cs
- DisposableCollectionWrapper.cs
- ButtonPopupAdapter.cs
- HealthMonitoringSectionHelper.cs
- IHttpResponseInternal.cs
- Encoder.cs
- DbTransaction.cs
- HybridObjectCache.cs
- messageonlyhwndwrapper.cs
- MaterialGroup.cs
- TypeViewSchema.cs
- WebPartTransformerCollection.cs
- MarshalByValueComponent.cs
- RemoteWebConfigurationHostServer.cs
- HttpResponseMessageProperty.cs
- LinearQuaternionKeyFrame.cs
- ScaleTransform3D.cs
- Scene3D.cs
- CodeCastExpression.cs
- ContentPresenter.cs
- SoapFault.cs
- AsyncResult.cs
- DataGridLinkButton.cs
- EdgeModeValidation.cs
- QueryCacheKey.cs
- IntSecurity.cs
- DependencyObjectPropertyDescriptor.cs
- TreeViewCancelEvent.cs
- SoapIgnoreAttribute.cs
- HiddenField.cs
- Speller.cs
- TypeDescriptionProviderAttribute.cs
- GlyphShapingProperties.cs
- XamlTreeBuilderBamlRecordWriter.cs
- BaseCollection.cs
- SupportingTokenListenerFactory.cs
- RoleManagerSection.cs
- ProfileBuildProvider.cs
- SubtreeProcessor.cs
- MetadataFile.cs
- XmlConvert.cs
- TextControl.cs
- State.cs
- ProfileProvider.cs
- FontStretchConverter.cs
- ToolStripSettings.cs
- SafeNativeMethods.cs
- TraceLevelStore.cs
- NamedObjectList.cs
- WorkflowStateRollbackService.cs
- TemplatedWizardStep.cs
- HitTestParameters.cs
- Axis.cs
- SqlCacheDependency.cs
- FlowSwitch.cs
- Grid.cs
- TypeReference.cs
- QueryConverter.cs
- SimpleWorkerRequest.cs
- CodeDirectionExpression.cs
- PixelFormats.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- Literal.cs
- PageFunction.cs
- SqlExpressionNullability.cs
- ImageField.cs
- EntityDataSourceContextDisposingEventArgs.cs
- DbConnectionPool.cs
- WebPartCatalogAddVerb.cs
- SoapCodeExporter.cs
- ManagementEventWatcher.cs
- StrongNameMembershipCondition.cs
- WebPartConnection.cs
- HttpResponse.cs
- WebEvents.cs
- mongolianshape.cs
- ClientCultureInfo.cs
- ErrorTableItemStyle.cs
- InkPresenterAutomationPeer.cs
- SecureConversationSecurityTokenParameters.cs
- SignatureResourceHelper.cs
- WebPartConnectionsEventArgs.cs
- HtmlCalendarAdapter.cs
- FloatAverageAggregationOperator.cs
- UIElementParaClient.cs
- ColorConverter.cs
- HtmlDocument.cs
- ExceptionDetail.cs
- _SSPISessionCache.cs
- UnknownBitmapEncoder.cs
- SHA1Managed.cs
- Int16.cs
- DeflateStream.cs