private RequestedAction DisplayDefine(GlobalDefines.Define inDefine) { RequestedAction action = RequestedAction.None; EditorGUILayout.BeginHorizontal(GUILayout.Height(LINE_HEIGHT)); { // Button to delete it if (GUILayout.Button("X", GUILayout.Width(24))) { action = RequestedAction.Delete; } // Name of the configuration string newName = EditorGUILayout.TextField(inDefine.Name); if (!string.IsNullOrEmpty(newName) && newName.IndexOf(' ') < 0) { inDefine.Name = newName; } // If it's enabled bool newEnabled = EditorGUILayout.Toggle(inDefine.Enabled, GUILayout.Width(16)); inDefine.Enabled = newEnabled; } EditorGUILayout.EndHorizontal(); return(action); }
Type HandleInfoMessage(string msg) { if (msg.Length == 25) // 25 because I don't count the '\n' { RoadID roadID = (RoadID)msg[1]; if (Enum.IsDefined(typeof(RoadID), roadID)) { if (msg[2] == '1' || msg[2] == '0') { bool isEmpty = msg[2] == '1'; string manufacturer = msg.Substring(3, 8).Trim(); string model = msg.Substring(11, 8).Trim(); int orientation = Convert.ToInt32(msg.Substring(19, 3).Trim()); Priority priority = (Priority)msg[22]; RequestedAction requestedAction = (RequestedAction)msg[23]; CurrentAction currentAction = (CurrentAction)msg[24]; if (Enum.IsDefined(typeof(Priority), priority) || Enum.IsDefined(typeof(RequestedAction), requestedAction) || Enum.IsDefined(typeof(CurrentAction), currentAction)) { monitor.UpdateRoad(roadID, isEmpty, orientation, manufacturer, model, priority, requestedAction, currentAction); return(Type.Info); } } } } return(Type.None); }
public RequestedAction ExecuteWorkItem(WorkItem workItem) { Fx.Assert(this.activityExecutor != null, "ActivityExecutor null in ExecuteWorkItem."); // We check the Verbose flag to avoid the // virt call if possible if (FxTrace.ShouldTraceVerboseToTraceSource) { workItem.TraceStarting(); } RequestedAction action = this.activityExecutor.OnExecuteWorkItem(workItem); if (!object.ReferenceEquals(action, Scheduler.YieldSilently)) { if (this.activityExecutor.IsAbortPending || this.activityExecutor.IsTerminatePending) { action = Scheduler.Abort; } // if the caller yields, then the work item is still active and the callback // is responsible for releasing it back to the pool workItem.Dispose(this.activityExecutor); } return(action); }
public void UpdateRoad(RoadID roadID, bool isEmpty, int orientation, string manufacturer, string model, Priority priority, RequestedAction requestedAction, CurrentAction currentAction) { Road r; if (!crossroad.TryGetValue(roadID, out r)) { r = new Road(roadID); crossroad.Add(roadID, r); } if (isEmpty) { r.RemoveCar(); } else { r.IsEmpty = isEmpty; r.Orientation = orientation; r.Manufacturer = manufacturer; r.Model = model; r.Priority = priority; r.RequestedAction = requestedAction; r.CurrentAction = currentAction; } window.UpdateRoad(r); }
private bool ObtainTokensViaNewApi(string mailboxServer, Guid mailboxGuid, RequestedAction requestedAction, int requestedTokenCount, int quota, string clientInfo) { ThrottlingRpcClientImpl rpcClient = this.GetRpcClient(mailboxServer); ThrottlingRpcResult result = rpcClient.ObtainTokens(mailboxGuid, requestedAction, requestedTokenCount, quota, clientInfo); return(MailboxThrottle.ThrottlingRpcResultToBoolean(result)); }
public void ShouldCopyMetadataWhenRequested() { CopyMetadataPlugin plugin = new CopyMetadataPlugin(); using (ImageState state = CreateImageState(true)) { RequestedAction requestedAction = CallProcessFinalBitmap(plugin, state); Assert.Equal(RequestedAction.None, requestedAction); Assert.NotEmpty(state.destBitmap.PropertyIdList); Assert.NotEmpty(state.destBitmap.PropertyItems); // Ensure that all the properties came from the original image... foreach (PropertyItem prop in state.destBitmap.PropertyItems) { PropertyItem sourceProp = state.sourceBitmap.PropertyItems.SingleOrDefault(p => p.Id == prop.Id); Assert.NotNull(sourceProp);//, "destBitmap ended up with a property that sourceBitmap didn't have!"); Assert.Equal(sourceProp.Len, prop.Len); Assert.Equal(sourceProp.Type, prop.Type); Assert.Equal(sourceProp.Len, prop.Len); Assert.Equal(sourceProp.Value, prop.Value); } } }
public void CopiedAndOriginalMetadataIncludesGeolocationInformation() { CopyMetadataPlugin plugin = new CopyMetadataPlugin(); using (ImageState state = CreateImageState(true)) { RequestedAction requestedAction = CallProcessFinalBitmap(plugin, state); Assert.Equal(RequestedAction.None, requestedAction); // Make sure geolocation properties got copied... int[] geolocationProperties = new int[] { 0x0000, // PropertyTagGpsVer 0x0001, // PropertyTagGpsLatitudeRef 0x0002, // PropertyTagGpsLatitude 0x0003, // PropertyTagGpsLongitudeRef 0x0004, // PropertyTagGpsLongitude 0x0005, // PropertyTagGpsAltitudeRef 0x0006, // PropertyTagGpsAltitude }; foreach (int propId in geolocationProperties) { Assert.Single(state.sourceBitmap.PropertyItems, prop => prop.Id == propId); //, "sourceBitmap did not include geolocation information!"); Assert.Single(state.destBitmap.PropertyItems, prop => prop.Id == propId); //, "destBitmap did not copy geolocation information!"); } } }
private RequestedAction DisplayConfiguration(GlobalDefines.Configuration inConfiguration) { RequestedAction action = RequestedAction.None; EditorGUILayout.BeginHorizontal(GUILayout.Height(LINE_HEIGHT)); { // Button to delete it if (GlobalDefines.Instance.Configurations.Count > 1) { if (GUILayout.Button("X", GUILayout.Width(24))) { action = RequestedAction.Delete; } } // Name of the configuration string newName = EditorGUILayout.TextField(inConfiguration.Name); if (!string.IsNullOrEmpty(newName)) { inConfiguration.Name = newName; } if (m_HighlightedConfiguration != inConfiguration) { // Button to select it if (GUILayout.Button("...", GUILayout.Width(48))) { action = RequestedAction.Select; } } } EditorGUILayout.EndHorizontal(); return(action); }
public IPersistable[] GetDataFromServer(RequestedAction action) { byte[] buffer = Serializer <ClientRequest> .Serialize(new ClientRequest(action)); byte[] bufferReceiver = Transmit(buffer); return(Serializer <TransmissionData> .Deserialize(bufferReceiver).Entities); }
private void DisplayDefines() { EditorGUILayout.BeginVertical(); { // Title of column EditorGUILayout.BeginHorizontal(GUILayout.Height(LINE_HEIGHT)); GUILayout.FlexibleSpace(); GUILayout.Label("Defines"); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); m_DefinesToDelete.Clear(); // All defines foreach (GlobalDefines.Define define in m_HighlightedConfiguration.Defines) { RequestedAction action = DisplayDefine(define); if (action == RequestedAction.Delete) { m_DefinesToDelete.Add(define); } } foreach (GlobalDefines.Define define in m_DefinesToDelete) { m_HighlightedConfiguration.Defines.Remove(define); } if (DisplayNewButton() == RequestedAction.Create) { m_HighlightedConfiguration.Defines.Add(new GlobalDefines.Define("NEW_DEFINE", false)); } } EditorGUILayout.EndVertical(); }
/// <summary> /// Adds alternate pipeline based on WIC. Invoked by &builder=wic. /// This method doesn't handle job.DisposeSource or job.DesposeDest or settings filtering, that's handled by ImageBuilder. /// Handles all the work for turning 'source' into a byte[]/long pair. /// </summary> /// <param name="job"></param> /// <returns></returns> protected override RequestedAction BuildJob(ImageJob job) { if (!"wic".Equals(job.Settings["builder"])) { return(RequestedAction.None); } //Convert the source stream to a byte[] array and length. byte[] data = null; long lData = 0; //This step gets a Stream instance, copies it to a MemoryStream, then accesses the underlying buffer to get the byte[] and length we need. Stream s = null; bool disposeStream = !(job.Source is Stream); long originalPosition = 0; bool restoreStreamPosition = false; try { //Get a Stream instance for the job string path; s = c.CurrentImageBuilder.GetStreamFromSource(job.Source, job.Settings, ref disposeStream, out path, out restoreStreamPosition); if (s == null) { return(RequestedAction.None); //We don't support the source object! } if (job.ResetSourceStream) { restoreStreamPosition = true; } job.SourcePathData = path; //Save the original stream positione originalPosition = (restoreStreamPosition) ? s.Position : -1; data = StreamExtensions.CopyOrReturnBuffer(s, out lData, false, 0x1000); } finally { if (s != null && restoreStreamPosition && s.CanSeek) { s.Seek(originalPosition, SeekOrigin.Begin); } if (disposeStream) { s.Dispose(); } } //Ok, now we have our byte[] and length. //Let's find out if transparency is supported. IEncoder managedEncoder = c.Plugins.GetEncoder(job.Settings, job.SourcePathData); bool supportsTransparency = managedEncoder.SupportsTransparency; RequestedAction result = BuildJobWic(data, lData, job, supportsTransparency); GC.KeepAlive(data); return(result); }
// Token: 0x06000022 RID: 34 RVA: 0x000025C4 File Offset: 0x000007C4 public override byte[] ObtainTokens(byte[] request) { byte[] result; try { RequestedAction requestedAction = RequestedAction.Invalid; Guid mailboxGuid = Guid.Empty; int requestedTokenCount = 0; int totalTokenCount = 0; string clientHostName = null; string clientProcessName = null; string clientType = null; MdbefPropertyCollection mdbefPropertyCollection = MdbefPropertyCollection.Create(request, 0, request.Length); object obj; if (mdbefPropertyCollection.TryGetValue(2415984712U, out obj) && obj is Guid) { mailboxGuid = (Guid)obj; } if (mdbefPropertyCollection.TryGetValue(2416050179U, out obj) && obj is int) { requestedAction = (RequestedAction)((int)obj); } if (mdbefPropertyCollection.TryGetValue(2416115715U, out obj) && obj is int) { requestedTokenCount = (int)obj; } if (mdbefPropertyCollection.TryGetValue(2416181251U, out obj) && obj is int) { totalTokenCount = (int)obj; } if (mdbefPropertyCollection.TryGetValue(2416312351U, out obj) && obj != null && obj is string) { clientHostName = (string)obj; } if (mdbefPropertyCollection.TryGetValue(2416377887U, out obj) && obj != null && obj is string) { clientProcessName = (string)obj; } if (mdbefPropertyCollection.TryGetValue(2416246815U, out obj) && obj != null && obj is string) { clientType = (string)obj; } bool flag = this.ObtainTokens(mailboxGuid, requestedAction, requestedTokenCount, totalTokenCount, clientHostName, clientProcessName, clientType); byte[] bytes = new MdbefPropertyCollection { { 2566914059U, flag } }.GetBytes(); result = bytes; } catch (Exception exception) { ExWatson.SendReportAndCrashOnAnotherThread(exception); result = null; } return(result); }
public void ApplyRequestedAction(RequestedAction action) { Self.Position += action.Move; if (action.DropBomb) { Self.Bomb = new BombState(Self.BombFuze, Self.BombRadius, Self.Position); } }
public IPersistable SentRequestToServer(RequestedAction action, IPersistable data) { TransmissionData transmitData = new TransmissionData(data); byte[] buffer = Serializer <ClientRequest> .Serialize(new ClientRequest(action, transmitData)); byte[] bufferReceiver = Transmit(buffer); return(Serializer <TransmissionData> .Deserialize(bufferReceiver).Entity); }
public ThrottlingRpcResult ObtainTokens(Guid mailboxGuid, RequestedAction requestedAction, int requestedTokenCount, int totalTokenCount, string clientInfo) { this.ThrowIfDisposed(); ThrottlingRpcClient throttlingRpcClient; if (!this.TryGetRpcClient(out throttlingRpcClient)) { ThrottlingRpcClientImpl.tracer.TraceDebug(0L, "Bypassed RPC for mailbox server {0} and mailbox GUID <{1}> because of failure count {2} and last failure time {3}", new object[] { this.serverName, mailboxGuid, this.failureCount, this.lastFailureTime }); this.perfCounters.AddRequestStatus(ThrottlingRpcResult.Bypassed); return(ThrottlingRpcResult.Bypassed); } long requestStartTime = 0L; long requestCompletionTime = 0L; ThrottlingRpcResult throttlingRpcResult; try { ThrottlingRpcClientImpl.tracer.TraceDebug(0L, "Invoking RPC for mailbox server {0}, mailbox GUID <{1}>, requestedAction {2}, requestedTokenCount {3}, totalTokenCount {4}", new object[] { this.serverName, mailboxGuid, requestedAction, requestedTokenCount, totalTokenCount }); byte[] inBytes = ThrottlingRpcClientImpl.PackRequest(mailboxGuid, requestedAction, requestedTokenCount, totalTokenCount, clientInfo); requestStartTime = Stopwatch.GetTimestamp(); byte[] responseByteArray = throttlingRpcClient.ObtainTokens(inBytes); requestCompletionTime = Stopwatch.GetTimestamp(); bool flag; ThrottlingRpcClientImpl.UnpackResponse(responseByteArray, out flag); ThrottlingRpcClientImpl.tracer.TraceDebug <bool>(0L, "RPC request succeeded and returned {0}", flag); throttlingRpcResult = (flag ? ThrottlingRpcResult.Allowed : ThrottlingRpcResult.Denied); } catch (RpcException ex) { requestCompletionTime = Stopwatch.GetTimestamp(); ThrottlingRpcClientImpl.tracer.TraceError <string, RpcException>(0L, "Exception in RPC request to mailbox server {0}: {1}", this.serverName, ex); ThrottlingRpcClientImpl.EventLogger.LogEvent(ThrottlingClientEventLogConstants.Tuple_RpcClientOperationFailure, this.serverName, new object[] { this.serverName, ex.ErrorCode, ex, (ex.InnerException != null) ? ex.InnerException.ToString() : "none" }); throttlingRpcResult = ThrottlingRpcResult.Failed; } this.HandleResult(throttlingRpcResult, requestStartTime, requestCompletionTime, throttlingRpcClient); return(throttlingRpcResult); }
public void ShouldNotCopyMetadataWhenNotRequested() { CopyMetadataPlugin plugin = new CopyMetadataPlugin(); using (ImageState state = CreateImageState(false)) { RequestedAction requestedAction = CallProcessFinalBitmap(plugin, state); Assert.Equal(RequestedAction.None, requestedAction); Assert.Empty(state.destBitmap.PropertyIdList); Assert.Empty(state.destBitmap.PropertyItems); } }
private static RequestedAction CallProcessFinalBitmap(BuilderExtension plugin, ImageState state) { var type = plugin.GetType(); var method = type.GetMethod("ProcessFinalBitmap", BindingFlags.Instance | BindingFlags.NonPublic); Assert.NotNull(method);//, "Did not find 'ProcessFinalBitmap' method on plugin."); RequestedAction requestedAction = (RequestedAction)method.Invoke(plugin, new object[] { state }); return(requestedAction); }
// Token: 0x06000029 RID: 41 RVA: 0x00002B18 File Offset: 0x00000D18 private bool ObtainTokens(Guid mailboxGuid, RequestedAction requestedAction, int requestedTokenCount, int totalTokenCount, string clientHostName, string clientProcessName, string clientType) { ThrottlingService.Tracer.TraceDebug(0L, "ObtainTokens() request: mailboxGuid=<{0}>; requestedAction={1}; requestedTokenCount={2}; totalTokenCount={3}", new object[] { mailboxGuid, requestedAction, requestedTokenCount, totalTokenCount }); ObtainTokensRequest <Guid> request = new ObtainTokensRequest <Guid>(mailboxGuid, requestedTokenCount, totalTokenCount, requestedAction, clientHostName, clientProcessName, clientType); bool flag; if (totalTokenCount < 1 || requestedTokenCount < 1 || requestedTokenCount > totalTokenCount) { ThrottlingService.Tracer.TraceError(0L, "ObtainSubmissionTokens(): invalid arguments supplied"); flag = false; } else if (requestedAction == RequestedAction.UserMailSubmission) { flag = this.userSubmissionTokens.ObtainTokens(request); } else if (requestedAction == RequestedAction.MailboxRuleMailSubmission) { flag = this.mailboxRuleSubmissionTokens.ObtainTokens(request); } else { ThrottlingServiceLog.LogThrottlingBypassed <Guid>(request); ThrottlingService.Tracer.TraceDebug <RequestedAction>(0L, "Action {1} is not supported, therefor is allowed by default", requestedAction); flag = true; } if (flag) { ThrottlingService.Tracer.TraceDebug(0L, "ObtainTokens(): request allowed"); } else { ThrottlingService.EventLogger.LogEvent(ThrottlingServiceEventLogConstants.Tuple_MailboxThrottled, mailboxGuid.ToString(), new object[] { mailboxGuid, clientHostName, requestedAction, requestedTokenCount, totalTokenCount, clientType, clientProcessName }); ThrottlingService.Tracer.TraceDebug(0L, "ObtainTokens(): request denied"); } return(flag); }
void InitializeCommands() { RedoCommand = new RelayCommand(() => { RequestedAction?.Invoke(RequestedCommand.Redo); Close(); }); NextCommand = new RelayCommand(() => { RequestedAction?.Invoke(RequestedCommand.Next); Close(); }); }
public IPersistable[] SentRequestToServer(RequestedAction action, List <IPersistable> data) { if (!client.Connected) { client.Connect(remoteEndPoint); } TransmissionData transmitData = new TransmissionData(data); byte[] buffer = Serializer <ClientRequest> .Serialize(new ClientRequest(action, transmitData)); byte[] bufferReceiver = Transmit(buffer); client.Dispose(); return(Serializer <TransmissionData> .Deserialize(bufferReceiver).Entities); }
// Log the event and sync up public void ProcessAction(string id, RequestedAction action, string team1 = null, string team2 = null) { switch (action) { case RequestedAction.Undo: _eventBus.Send(new UndoCommand(id)); break; case RequestedAction.Create: _eventBus.Send(new CreateMatchCommand(id, team1, team2)); break; case RequestedAction.Start: _eventBus.RaiseEvent(new MatchStatusChangedEvent(id, EventType.Start)); break; case RequestedAction.Finish: _eventBus.RaiseEvent(new MatchStatusChangedEvent(id, EventType.End)); break; case RequestedAction.Resume: _eventBus.RaiseEvent(new MatchStatusChangedEvent(id, EventType.Resume)); break; case RequestedAction.PeriodStart: _eventBus.RaiseEvent(new MatchStatusChangedEvent(id, EventType.Period)); break; case RequestedAction.PeriodEnd: _eventBus.RaiseEvent(new MatchStatusChangedEvent(id, EventType.EndPeriod)); break; case RequestedAction.Goal1: _eventBus.Send(new ScoreGoalCommand(id, TeamId.Home, GetRandomPlayerId())); break; case RequestedAction.Goal2: _eventBus.Send(new ScoreGoalCommand(id, TeamId.Visitors, GetRandomPlayerId())); break; case RequestedAction.TimeoutRequest1: _eventBus.Send(new RequestTimeoutCommand(id, TeamId.Home)); break; case RequestedAction.TimeoutRequest2: _eventBus.Send(new RequestTimeoutCommand(id, TeamId.Visitors)); break; } }
private static byte[] PackRequest(Guid mailboxGuid, RequestedAction requestedAction, int requestedTokenCount, int totalTokenCount, string clientInfo) { MdbefPropertyCollection mdbefPropertyCollection = new MdbefPropertyCollection(); mdbefPropertyCollection.Add(2415984712U, mailboxGuid); mdbefPropertyCollection.Add(2416050179U, (int)requestedAction); mdbefPropertyCollection.Add(2416115715U, requestedTokenCount); mdbefPropertyCollection.Add(2416181251U, totalTokenCount); mdbefPropertyCollection.Add(2416312351U, Environment.MachineName); mdbefPropertyCollection.Add(2416377887U, ThrottlingRpcClientImpl.currentProcess.ProcessName); if (!string.IsNullOrEmpty(clientInfo)) { mdbefPropertyCollection.Add(2416246815U, clientInfo); } return(mdbefPropertyCollection.GetBytes()); }
private static RequestedAction CallProcessFinalBitmap(BuilderExtension plugin, ImageState state) { ITypeInfo type = Reflector.Wrap(plugin.GetType()); IMethodInfo method = type.GetMethod("ProcessFinalBitmap", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(method, "Did not find 'ProcessFinalBitmap' method on plugin."); MethodInfo m = method.Resolve(false); Assert.IsNotNull(m); RequestedAction requestedAction = (RequestedAction)m.Invoke(plugin, new object[] { state }); return(requestedAction); }
private RequestedAction DisplayNewButton() { RequestedAction action = RequestedAction.None; EditorGUILayout.BeginHorizontal(GUILayout.Height(LINE_HEIGHT)); { // Button to delete it if (GUILayout.Button("+")) { action = RequestedAction.Create; } } EditorGUILayout.EndHorizontal(); return(action); }
public RequestedAction GetBestAction() { float bestWinRate = 0; RequestedAction bestAction = null; foreach (KeyValuePair <MoveType, Node> pair in Children) { float winRate = pair.Value.Result.WinRate; if (winRate >= bestWinRate) { bestWinRate = winRate; bestAction = MoveTypeToRequestedAction(pair.Key); } } return(bestAction); }
public bool FDispatchCmdLineSwitch(TCore.CmdLine.CmdLineSwitch cls, string sParam, object oClient, out string sError) { sError = ""; if (cls.Switch == "PW") { ShowPassword = true; } else if (cls.Switch == "R") { m_sSqlFile = sParam; } else if (cls.Switch == "L") { m_sLogFile = sParam; } else if (cls.Switch == "C") { m_sLocalCoverRoot = sParam; } else if (cls.Switch == "B") { m_action = RequestedAction.Books; } else if (cls.Switch == "D") { m_action = RequestedAction.Dvds; } else if (cls.Switch == "Bs" || cls.Switch == "Ds") { m_fForceUpdateSummary = !m_fForceUpdateSummary; } else { sError = $"Invalid switch {cls.Switch}"; return(false); } return(true); }
private RequestedAction InstallOrUpgradeModule(ModuleInfo moduleInfo) { RequestedAction requestedAction = RequestedAction.None; var version = moduleInfo.Module.GetType().Assembly.GetName().Version; if (moduleInfo.Config.Version == null) { var context = new DefaultInstallContext(this); moduleInfo.Module.Install(context); requestedAction = context.RequestedAction; moduleInfo.Config.Version = version; } else if (moduleInfo.Config.Version < version) { var context = new DefaultUpgradeContext(this, moduleInfo.Config.Version); moduleInfo.Module.Upgrade(context); requestedAction = context.RequestedAction; moduleInfo.Config.Version = version; } return(requestedAction); }
public void ShouldNeverCopyExcludedProperties() { CopyMetadataPlugin plugin = new CopyMetadataPlugin(); using (ImageState state = CreateImageState(true)) { RequestedAction requestedAction = CallProcessFinalBitmap(plugin, state); Assert.Equal(RequestedAction.None, requestedAction); // Make sure some of properties were stripped... // PropertyTagOrientation Assert.True(state.sourceBitmap.PropertyItems.Any(prop => prop.Id == 0x0112)); Assert.False(state.destBitmap.PropertyItems.Any(prop => prop.Id == 0x0112)); // PropertyTagXResolution Assert.True(state.sourceBitmap.PropertyItems.Any(prop => prop.Id == 0x011A)); Assert.False(state.destBitmap.PropertyItems.Any(prop => prop.Id == 0x011A)); // PropertyTagYResolution Assert.Single(state.sourceBitmap.PropertyItems, prop => prop.Id == 0x011B); Assert.False(state.destBitmap.PropertyItems.Any(prop => prop.Id == 0x011B)); } }
public void InternalResume(RequestedAction action) { bool shouldTraceInformation = FxTrace.ShouldTraceInformation; bool flag2 = false; bool isCompleted = false; if (this.callbacks.IsAbortPending) { this.isPausing = false; this.isRunning = false; this.NotifyWorkCompletion(); flag2 = true; if (shouldTraceInformation) { isCompleted = this.callbacks.IsCompleted; } this.callbacks.SchedulerIdle(); } else if (object.ReferenceEquals(action, continueAction)) { this.ScheduleWork(false); } else { NotifyUnhandledExceptionAction action2 = (NotifyUnhandledExceptionAction) action; this.isRunning = false; this.NotifyWorkCompletion(); flag2 = true; if (shouldTraceInformation) { isCompleted = this.callbacks.IsCompleted; } this.callbacks.NotifyUnhandledException(action2.Exception, action2.Source); } if (shouldTraceInformation && flag2) { Guid empty = Guid.Empty; bool flag4 = false; if (isCompleted) { if (TD.WorkflowActivityStopIsEnabled()) { empty = DiagnosticTrace.ActivityId; DiagnosticTrace.ActivityId = this.callbacks.WorkflowInstanceId; flag4 = true; TD.WorkflowActivityStop(this.callbacks.WorkflowInstanceId.ToString()); } } else if (TD.WorkflowActivitySuspendIsEnabled()) { empty = DiagnosticTrace.ActivityId; DiagnosticTrace.ActivityId = this.callbacks.WorkflowInstanceId; flag4 = true; TD.WorkflowActivitySuspend(this.callbacks.WorkflowInstanceId.ToString()); } if (flag4) { DiagnosticTrace.ActivityId = empty; } } }
private static void OnScheduledWork(object state) { Scheduler thisPtr = (Scheduler)state; // We snapshot these values here so that we can // use them after calling OnSchedulerIdle. //bool isTracingEnabled = FxTrace.Trace.ShouldTraceToTraceSource(TraceEventLevel.Informational); Guid oldActivityId = Guid.Empty; Guid workflowInstanceId = Guid.Empty; //if (isTracingEnabled) //{ // oldActivityId = DiagnosticTraceBase.ActivityId; // workflowInstanceId = thisPtr.callbacks.WorkflowInstanceId; // FxTrace.Trace.SetAndTraceTransfer(workflowInstanceId, true); // if (thisPtr.resumeTraceRequired) // { // if (TD.WorkflowActivityResumeIsEnabled()) // { // TD.WorkflowActivityResume(workflowInstanceId); // } // } //} thisPtr.callbacks.ThreadAcquired(); RequestedAction nextAction = continueAction; bool idleOrPaused = false; while (object.ReferenceEquals(nextAction, continueAction)) { if (thisPtr.IsIdle || thisPtr.isPausing) { idleOrPaused = true; break; } // cycle through (queue->thisPtr.firstWorkItem->currentWorkItem) WorkItem currentWorkItem = thisPtr.firstWorkItem; // promote an item out of our work queue if necessary if (thisPtr.workItemQueue != null && thisPtr.workItemQueue.Count > 0) { thisPtr.firstWorkItem = thisPtr.workItemQueue.Dequeue(); } else { thisPtr.firstWorkItem = null; } if (TD.ExecuteWorkItemStartIsEnabled()) { TD.ExecuteWorkItemStart(); } nextAction = thisPtr.callbacks.ExecuteWorkItem(currentWorkItem); if (TD.ExecuteWorkItemStopIsEnabled()) { TD.ExecuteWorkItemStop(); } } //bool notifiedCompletion = false; //bool isInstanceComplete = false; if (idleOrPaused || object.ReferenceEquals(nextAction, abortAction)) { thisPtr.isPausing = false; thisPtr.isRunning = false; thisPtr.NotifyWorkCompletion(); //notifiedCompletion = true; //if (isTracingEnabled) //{ // isInstanceComplete = thisPtr.callbacks.IsCompleted; //} // After calling SchedulerIdle we no longer have the lock. That means // that any subsequent processing in this method won't have the single // threaded guarantee. thisPtr.callbacks.SchedulerIdle(); } else if (!object.ReferenceEquals(nextAction, yieldSilentlyAction)) { Fx.Assert(nextAction is NotifyUnhandledExceptionAction, "This is the only other option"); NotifyUnhandledExceptionAction notifyAction = (NotifyUnhandledExceptionAction)nextAction; // We only set isRunning back to false so that the host doesn't // have to treat this like a pause notification. As an example, // a host could turn around and call run again in response to // UnhandledException without having to go through its operation // dispatch loop first (or request pause again). If we reset // isPausing here then any outstanding operations wouldn't get // signaled with that type of host. thisPtr.isRunning = false; thisPtr.NotifyWorkCompletion(); //notifiedCompletion = true; //if (isTracingEnabled) //{ // isInstanceComplete = thisPtr.callbacks.IsCompleted; //} thisPtr.callbacks.NotifyUnhandledException(notifyAction.Exception, notifyAction.Source); } //if (isTracingEnabled) //{ // if (notifiedCompletion) // { // if (isInstanceComplete) // { // if (TD.WorkflowActivityStopIsEnabled()) // { // TD.WorkflowActivityStop(workflowInstanceId); // } // } // else // { // if (TD.WorkflowActivitySuspendIsEnabled()) // { // TD.WorkflowActivitySuspend(workflowInstanceId); // } // } // } // DiagnosticTraceBase.ActivityId = oldActivityId; //} }
// This method should only be called when we relinquished the thread but did not // complete the operation (silent yield is the current example) public void InternalResume(RequestedAction action) { Fx.Assert(this.isRunning, "We should still be processing work - we just don't have a thread"); bool isTracingEnabled = FxTrace.ShouldTraceInformation; bool notifiedCompletion = false; bool isInstanceComplete = false; if (this.callbacks.IsAbortPending) { this.isPausing = false; this.isRunning = false; this.NotifyWorkCompletion(); notifiedCompletion = true; if (isTracingEnabled) { isInstanceComplete = this.callbacks.IsCompleted; } // After calling SchedulerIdle we no longer have the lock. That means // that any subsequent processing in this method won't have the single // threaded guarantee. this.callbacks.SchedulerIdle(); } else if (object.ReferenceEquals(action, continueAction)) { ScheduleWork(false); } else { Fx.Assert(action is NotifyUnhandledExceptionAction, "This is the only other choice because we should never have YieldSilently here"); NotifyUnhandledExceptionAction notifyAction = (NotifyUnhandledExceptionAction)action; // We only set isRunning back to false so that the host doesn't // have to treat this like a pause notification. As an example, // a host could turn around and call run again in response to // UnhandledException without having to go through its operation // dispatch loop first (or request pause again). If we reset // isPausing here then any outstanding operations wouldn't get // signaled with that type of host. this.isRunning = false; this.NotifyWorkCompletion(); notifiedCompletion = true; if (isTracingEnabled) { isInstanceComplete = this.callbacks.IsCompleted; } this.callbacks.NotifyUnhandledException(notifyAction.Exception, notifyAction.Source); } if (isTracingEnabled) { if (notifiedCompletion) { Guid oldActivityId = Guid.Empty; bool resetId = false; if (isInstanceComplete) { if (TD.WorkflowActivityStopIsEnabled()) { oldActivityId = WfEventSource.CurrentThreadActivityId; WfEventSource.SetCurrentThreadActivityId(this.callbacks.WorkflowInstanceId); resetId = true; TD.WorkflowActivityStop(this.callbacks.WorkflowInstanceId); } } else { if (TD.WorkflowActivitySuspendIsEnabled()) { oldActivityId = WfEventSource.CurrentThreadActivityId; WfEventSource.SetCurrentThreadActivityId(this.callbacks.WorkflowInstanceId); resetId = true; TD.WorkflowActivitySuspend(this.callbacks.WorkflowInstanceId); } } if (resetId) { WfEventSource.SetCurrentThreadActivityId(oldActivityId); } } } }
// This method should only be called when we relinquished the thread but did not // complete the operation (silent yield is the current example) public void InternalResume(RequestedAction action) { Fx.Assert(this.isRunning, "We should still be processing work - we just don't have a thread"); bool isTracingEnabled = FxTrace.ShouldTraceInformation; bool notifiedCompletion = false; bool isInstanceComplete = false; if (this.callbacks.IsAbortPending) { this.isPausing = false; this.isRunning = false; this.NotifyWorkCompletion(); notifiedCompletion = true; if (isTracingEnabled) { isInstanceComplete = this.callbacks.IsCompleted; } // After calling SchedulerIdle we no longer have the lock. That means // that any subsequent processing in this method won't have the single // threaded guarantee. this.callbacks.SchedulerIdle(); } else if (object.ReferenceEquals(action, continueAction)) { ScheduleWork(false); } else { Fx.Assert(action is NotifyUnhandledExceptionAction, "This is the only other choice because we should never have YieldSilently here"); NotifyUnhandledExceptionAction notifyAction = (NotifyUnhandledExceptionAction)action; // We only set isRunning back to false so that the host doesn't // have to treat this like a pause notification. As an example, // a host could turn around and call run again in response to // UnhandledException without having to go through its operation // dispatch loop first (or request pause again). If we reset // isPausing here then any outstanding operations wouldn't get // signaled with that type of host. this.isRunning = false; this.NotifyWorkCompletion(); notifiedCompletion = true; if (isTracingEnabled) { isInstanceComplete = this.callbacks.IsCompleted; } this.callbacks.NotifyUnhandledException(notifyAction.Exception, notifyAction.Source); } if (isTracingEnabled) { if (notifiedCompletion) { Guid oldActivityId = Guid.Empty; bool resetId = false; if (isInstanceComplete) { if (TD.WorkflowActivityStopIsEnabled()) { oldActivityId = DiagnosticTraceBase.ActivityId; DiagnosticTraceBase.ActivityId = this.callbacks.WorkflowInstanceId; resetId = true; TD.WorkflowActivityStop(this.callbacks.WorkflowInstanceId); } } else { if (TD.WorkflowActivitySuspendIsEnabled()) { oldActivityId = DiagnosticTraceBase.ActivityId; DiagnosticTraceBase.ActivityId = this.callbacks.WorkflowInstanceId; resetId = true; TD.WorkflowActivitySuspend(this.callbacks.WorkflowInstanceId); } } if (resetId) { DiagnosticTraceBase.ActivityId = oldActivityId; } } } }