protected virtual void onGraphicalUpdate() { updateRigidbodyValues(); if (_mostRecentCallback == CallbackState.Physical || _mostRecentCallback == CallbackState.PhysicalNeedsUpdate) { _savedPosition = _rigidbody.position; _savedRotation = _rigidbody.rotation; } float t = (Time.time - Time.fixedTime) / Time.fixedDeltaTime; Vector3 interpolatedPosition = Vector3.Lerp(_prevRigidbodyPosition, _rigidbodyPosition, t); Quaternion interpolatedRotation = Quaternion.Slerp(_prevRigidbodyRotation, _rigidbodyRotation, t); if (_hasGraphicalTransform) { Quaternion inverseRotation = Quaternion.Inverse(interpolatedRotation); _graphicalPositionOffset = inverseRotation * (_graphicalPosition - interpolatedPosition); _graphicalRotationOffset = inverseRotation * _graphicalRotation; _hasGraphicalTransform = false; } _transform.position = interpolatedPosition + interpolatedRotation * (_graphicalPositionOffset) * _warpPercent; _transform.rotation = interpolatedRotation * Quaternion.Slerp(Quaternion.identity, _graphicalRotationOffset, _warpPercent); WarpPercent = Mathf.MoveTowards(WarpPercent, 0, Time.deltaTime / _returnTime); _mostRecentCallback = CallbackState.Graphical; }
public OpenCollectionAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, IList <ICommunicationObject> collection) : base(otherCallback, state) { this.timeoutHelper = new TimeoutHelper(timeout); this.completedSynchronously = true; this.count = collection.Count; if (this.count == 0) { base.Complete(true); } else { for (int i = 0; i < collection.Count; i++) { if (this.exception != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.exception); } CallbackState state2 = new CallbackState(this, collection[i]); IAsyncResult result = collection[i].BeginOpen(this.timeoutHelper.RemainingTime(), nestedCallback, state2); if (result.CompletedSynchronously) { collection[i].EndOpen(result); this.Decrement(true); } } } }
protected virtual void OnGetPublicServersCompleted(object sender, GetPublicServersCompletedEventArgs e) { if (e.Error != null) { OnError(this, new StorageSerErrorEventArgs(e.Error)); } else if (!e.Cancelled) { if (e.Result.Tables.Count > 0) { int[] ids = (from d in e.Result.Tables[0].Select() select d.Field <int>("Id")).ToArray(); DropPublicServers(ids); DropFavoriteServers(ids); ValidateServers(e.Result.Tables[0]); } OnServerUpdateComplete(this, EventArgs.Empty); } CallbackState state = e.UserState as CallbackState; if (state != null && state.Callback != null) { state.Callback(this, EventArgs.Empty); } }
protected virtual void OnGetServerInformationCompleted(object sender, GetServerInformationCompletedEventArgs e) { if (e.Error != null) { OnError(this, new StorageSerErrorEventArgs(e.Error)); } else if (!e.Cancelled) { if (e.Result.Tables.Count > 0 && e.Result.Tables[0].Rows.Count > 0) { DataRow data = e.Result.Tables[0].Rows[0]; Server server = (from s in PublicServers where data.Field <int>("Id") == s.Id select s).FirstOrDefault(); if (server != null) { UpdatePublicServer(server, data); _context.SaveChanges(); } } } CallbackState state = e.UserState as CallbackState; if (state != null && state.Callback != null) { state.Callback(this, EventArgs.Empty); } }
public void Configure(Configuration configuration, IEnumerable <IToggleScheduledTask> tasks, CancellationToken cancellationToken) { _cancellationToken = cancellationToken; foreach (var scheduledTask in tasks) { var dueTime = scheduledTask.Interval; var callbackState = new CallbackState { Name = scheduledTask.Name, DueTime = dueTime, Task = scheduledTask }; var timer = new Timer( callback: Callback, state: callbackState, dueTime: dueTime, period: Timeout.InfiniteTimeSpan); timers.Add(scheduledTask.Name, timer); //Task.Run(() => TimerLoopAsync(scheduledTask, cancellationToken), cancellationToken); } }
public OpenCollectionAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, IList <ICommunicationObject> collection) : base(otherCallback, state) { _timeoutHelper = new TimeoutHelper(timeout); _completedSynchronously = true; _count = collection.Count; if (_count == 0) { Complete(true); return; } for (int index = 0; index < collection.Count; index++) { // Throw exception if there was a failure calling EndOpen in the callback (skips remaining items) if (_exception != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(_exception); } CallbackState callbackState = new CallbackState(this, collection[index]); IAsyncResult result = collection[index].BeginOpen(_timeoutHelper.RemainingTime(), s_nestedCallback, callbackState); if (result.CompletedSynchronously) { collection[index].EndOpen(result); Decrement(true); } } }
protected virtual void OnGetLatestVersionCompleted(object sender, GetLatestVersionCompletedEventArgs e) { if (e.Error != null) { OnError(this, new StorageSerErrorEventArgs(e.Error)); } else if (!e.Cancelled) { if (e.Result.Tables.Count > 0 && e.Result.Tables[0].Rows.Count > 0) { Version version = new Version(e.Result.Tables[0].Rows[0].Field <string>("Version")); if (_applicationService.ApplicationInfo.Version.CompareTo(version) < 0) { Process.Start(Path.Combine(_applicationService.ApplicationInfo.BaseDirectory, "update.exe")); Process.GetCurrentProcess().Kill(); } } } CallbackState state = e.UserState as CallbackState; if (state != null && state.Callback != null) { state.Callback(this, EventArgs.Empty); } }
public ActionResult Permissions(string scope) { // connect with facebook if we have no token var token = repository.GetOAuthToken(subdomainid.Value, sessionid.Value.ToString(), OAuthTokenType.FACEBOOK); if (token == null) { //we need to get user to connect with facebook first return(Json(JavascriptReturnCodes.NOTOKEN.ToJsonOKData(), JsonRequestBehavior.AllowGet)); } var oauthClient = new FacebookOAuthClient(FacebookApplication.Current) { RedirectUri = GetFacebookRedirectUri() }; dynamic parameters = new ExpandoObject(); parameters.scope = scope; var state = new CallbackState() { return_url = Request.UrlReferrer != null ? Request.UrlReferrer.AbsoluteUri : accountHostname.ToDomainUrl("/dashboard"), requestPageTokens = true, domain_name = accountSubdomainName }; parameters.state = OAuthFacebook.Base64UrlEncode(Encoding.UTF8.GetBytes(JsonSerializer.Current.SerializeObject(state))); return(Redirect(oauthClient.GetLoginUrl(parameters).AbsoluteUri)); }
private void OnTransactionComplete(object sender, TransactionEventArgs e) { if (e.Transaction.TransactionInformation.Status == TransactionStatus.Aborted) { try { CallbackState state = new CallbackState { ChannelHandler = this.channelHandler, ReceiveContext = this.receiveContext }; IAsyncResult result = this.receiveContext.BeginAbandon(TimeSpan.MaxValue, abandonCallback, state); if (result.CompletedSynchronously) { this.receiveContext.EndAbandon(result); } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } this.channelHandler.HandleError(exception); } } }
protected unsafe void EnableActionState() { iCallbackState = new CallbackState(DoState); IntPtr ptr = GCHandle.ToIntPtr(iGch); DvServiceLinnCoUkDs1EnableActionState(iHandle, iCallbackState, ptr); }
/// <summary> /// The function starts the web server /// </summary> public void Start() { if (IsStarted) { return; } RootDirectory = Constants.Common.DomainsDir; var tries = 0; while (tries < 5) { try { var listener = new HttpListener(); listener.Prefixes.Add("http://" + "localhost:" + _port + "/"); listener.Start(); var state = new CallbackState(listener); ThreadPool.QueueUserWorkItem(Listen, state); IsStarted = true; break; } catch (Exception) { IsStarted = false; tries++; } } }
public OpenCollectionAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, IList<ICommunicationObject> collection) : base(otherCallback, state) { _timeoutHelper = new TimeoutHelper(timeout); _completedSynchronously = true; _count = collection.Count; if (_count == 0) { Complete(true); return; } for (int index = 0; index < collection.Count; index++) { // Throw exception if there was a failure calling EndOpen in the callback (skips remaining items) if (_exception != null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(_exception); CallbackState callbackState = new CallbackState(this, collection[index]); IAsyncResult result = collection[index].BeginOpen(_timeoutHelper.RemainingTime(), s_nestedCallback, callbackState); if (result.CompletedSynchronously) { collection[index].EndOpen(result); Decrement(true); } } }
private void DisposeRequestContext(System.ServiceModel.Channels.RequestContext context) { try { context.Close(); ReceiveContextRPCFacet receiveContext = this.ReceiveContext; if (receiveContext != null) { this.ReceiveContext = null; CallbackState state = new CallbackState { ChannelHandler = this.channelHandler, ReceiveContext = receiveContext }; IAsyncResult result = receiveContext.BeginComplete(TimeSpan.MaxValue, null, this.channelHandler, handleEndComplete, state); if (result.CompletedSynchronously) { receiveContext.EndComplete(result); } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } this.AbortRequestContext(context); this.channelHandler.HandleError(exception); } }
private void AbortRequestContext(System.ServiceModel.Channels.RequestContext requestContext) { try { requestContext.Abort(); ReceiveContextRPCFacet receiveContext = this.ReceiveContext; if (receiveContext != null) { this.ReceiveContext = null; CallbackState state = new CallbackState { ReceiveContext = receiveContext, ChannelHandler = this.channelHandler }; IAsyncResult result = receiveContext.BeginAbandon(TimeSpan.MaxValue, handleEndAbandon, state); if (result.CompletedSynchronously) { receiveContext.EndAbandon(result); } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } this.channelHandler.HandleError(exception); } }
public OpenCollectionAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, IList<ICommunicationObject> collection) : base(otherCallback, state) { this.timeoutHelper = new TimeoutHelper(timeout); this.completedSynchronously = true; this.count = collection.Count; if (this.count == 0) { base.Complete(true); } else { for (int i = 0; i < collection.Count; i++) { if (this.exception != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.exception); } CallbackState state2 = new CallbackState(this, collection[i]); IAsyncResult result = collection[i].BeginOpen(this.timeoutHelper.RemainingTime(), nestedCallback, state2); if (result.CompletedSynchronously) { collection[i].EndOpen(result); this.Decrement(true); } } } }
public ActionResult Login(string redirect) { // try to get from db first var oauthClient = new FacebookOAuthClient(FacebookApplication.Current) { RedirectUri = GetFacebookRedirectUri() }; var relativeUrl = "/login"; if (!string.IsNullOrEmpty(redirect)) { relativeUrl = string.Concat(relativeUrl, "?redirect=", HttpUtility.UrlEncode(redirect)); } dynamic parameters = new ExpandoObject(); var state = new CallbackState() { return_url = accountHostname.ToDomainUrl(relativeUrl), isLogin = true }; parameters.state = OAuthFacebook.Base64UrlEncode(Encoding.UTF8.GetBytes(JsonSerializer.Current.SerializeObject(state))); return(Redirect(oauthClient.GetLoginUrl(parameters).AbsoluteUri)); }
private static void Callback(IAsyncResult result) { if (!result.CompletedSynchronously) { CallbackState asyncState = (CallbackState)result.AsyncState; asyncState.Result.CompleteClose(asyncState.Instance, result); } }
void delayInitTimer_Tick(object sender, EventArgs e) { _delayInitTimer.Stop(); try { DirectoryInfo dir = new DirectoryInfo(_applicationService.ApplicationInfo.BaseDirectory); FileInfo[] files = dir.GetFiles("*.bak"); for (int i = 0; i < files.Length; i++) { try { Tracer.Verbose("Deleting backed up file {0}", files[i].Name); files[i].Delete(); } catch { } } state = new CallbackState(OnCheckForUpdatesComplete); _storageService.Error += new EventHandler <StorageSerErrorEventArgs>(Database_Error); try { #if !DEV new ConnectUOWebService().UpdateVersionStatsAsync(_storageService.Guid, _applicationService.ApplicationInfo.Version.ToString()); #endif } catch (Exception ex) { Tracer.Error(ex); } try { _storageService.CheckForUpdates(state); } catch (Exception ex) { Invoke((MethodInvoker) delegate() { lblStatus.Text = "Unable to contact webservice..."; }); Tracer.Error(ex); _finishedCheckForUpdate = true; } _closeTimer.Interval = 3000; _closeTimer.Tick += new EventHandler(t_Tick); _closeTimer.Start(); } catch (Exception ex) { Tracer.Fatal(ex); } }
public void CheckForUpdates(CallbackState state) { if (state == null) { state = new CallbackState(null); } _service.GetLatestVersionAsync(state); }
private void method_6(Exception exception_0, IMessageHandler interface37_0, object object_0) { CallbackState <ResultHandler> state = (CallbackState <ResultHandler>)object_0; if (state.Handler != null) { state.Handler(exception_0 == null, state.Tag); } }
protected void updateRigidbodyValues() { if (_mostRecentCallback == CallbackState.PhysicalNeedsUpdate) { _prevRigidbodyPosition = _rigidbodyPosition; _prevRigidbodyRotation = _rigidbodyRotation; _rigidbodyPosition = _rigidbody.position; _rigidbodyRotation = _rigidbody.rotation; _mostRecentCallback = CallbackState.Physical; } }
private static void Callback(IAsyncResult result) { if (result.CompletedSynchronously) { return; } CallbackState callbackState = (CallbackState)result.AsyncState; callbackState.Result.CompleteClose(callbackState.Instance, result); }
protected void subscribe() { _rigidbodyPosition = _prevRigidbodyPosition = _savedPosition = _rigidbody.position; _rigidbodyRotation = _prevRigidbodyRotation = _savedRotation = _rigidbody.rotation; _mostRecentCallback = CallbackState.PhysicalNeedsUpdate; _manager.OnGraphicalUpdate += onGraphicalUpdate; _manager.OnPrePhysicalUpdate += onPrePhysicalUpdate; _manager.OnPostPhysicalUpdate += onPostPhysicalUpdate; _subscribed = true; }
protected virtual void onPrePhysicalUpdate() { updateRigidbodyValues(); if (_mostRecentCallback == CallbackState.Graphical) { _transform.position = _savedPosition; _transform.rotation = _savedRotation; } _mostRecentCallback = CallbackState.Physical; }
public void UpdateServers(CallbackState state) { if (state == null) { state = new CallbackState(null); } CallbackState testState = new CallbackState(InternalUpdateServers); testState.Tag = state; _service.TestConnectionAsync(testState); }
protected virtual void OnGetPatchesCompleted(object sender, GetPatchesCompletedEventArgs e) { if (e.Error != null) { OnError(this, new StorageSerErrorEventArgs(e.Error)); } CallbackState state = e.UserState as CallbackState; if (state != null && state.Callback != null) { state.Callback(this, EventArgs.Empty); } }
private void UpdateSnakes() { foreach (Snake s in mSnakes) { SnakeUpdateFlag flag = s.Update(); if ((flag & SnakeUpdateFlag.Crash) > 0) { mCallbackState = CallbackState.LoseGame; } else if (flag == SnakeUpdateFlag.ReachedExit) { mCallbackState = CallbackState.WinGame; } } }
static void OnCompleted(IAsyncResult ar) { CallbackState state = (CallbackState)ar.AsyncState; ParallelAsyncResult <TWorkItem> thisPtr = state.AsyncResult; try { thisPtr.endCall(thisPtr.iteratorAsyncResult, state.AsyncData, ar); thisPtr.TryComplete(null, ar.CompletedSynchronously); } catch (Exception e) when(!Fx.IsFatal(e)) { thisPtr.TryComplete(e, ar.CompletedSynchronously); } }
static void OnCompleted(IAsyncResult ar) { CallbackState state = (CallbackState)ar.AsyncState; ParallelAsyncResult <TWorkItem> thisPtr = state.AsyncResult; try { thisPtr.endCall(thisPtr.iteratorAsyncResult, state.AsyncData, ar); thisPtr.TryComplete(null, false); } catch (Exception e) { thisPtr.TryComplete(e, false); } }
void WaitForStoreUnlock(HttpContext context, string sessionId, bool isReadonly) { AutoResetEvent are = new AutoResetEvent(false); TimerCallback tc = new TimerCallback(StoreUnlockWaitCallback); CallbackState cs = new CallbackState(context, are, sessionId, isReadonly); using (Timer timer = new Timer(tc, cs, 500, 500)) { try { are.WaitOne(executionTimeout, false); } catch { storeData = null; } } }
void StoreUnlockWaitCallback(object s) { CallbackState state = (CallbackState)s; GetStoreData(state.Context, state.SessionId, state.IsReadOnly); if (storeData == null && storeLocked && (storeLockAge > executionTimeout)) { handler.ReleaseItemExclusive(state.Context, state.SessionId, storeLockId); state.AutoEvent.Set(); } else if (storeData != null && !storeLocked) { state.AutoEvent.Set(); } }
protected virtual void OnTestConnectionCompleted(object sender, TestConnectionCompletedEventArgs e) { if (e.Error != null) { OnError(this, new StorageSerErrorEventArgs(e.Error)); } if (!e.Cancelled) { CallbackState state = e.UserState as CallbackState; if (state != null && state.Callback != null) { state.Callback(state, EventArgs.Empty); } } }
public CloseCollectionAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, IList<ICommunicationObject> collection) : base(otherCallback, state) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); _completedSynchronously = true; _count = collection.Count; if (_count == 0) { Complete(true); return; } for (int index = 0; index < collection.Count; index++) { CallbackState callbackState = new CallbackState(this, collection[index]); IAsyncResult result; try { result = collection[index].BeginClose(timeoutHelper.RemainingTime(), s_nestedCallback, callbackState); } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (Fx.IsFatal(e)) { throw; } Decrement(true, e); collection[index].Abort(); continue; } if (result.CompletedSynchronously) { CompleteClose(collection[index], result); } } }
void WaitForStoreUnlock (HttpContext context, string sessionId, bool isReadonly) { AutoResetEvent are = new AutoResetEvent (false); TimerCallback tc = new TimerCallback (StoreUnlockWaitCallback); CallbackState cs = new CallbackState (context, are, sessionId, isReadonly); using (Timer timer = new Timer (tc, cs, 500, 500)) { try { are.WaitOne (executionTimeout, false); } catch { storeData = null; } } }
public CloseInputAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, InstanceContext[] instances) : base(otherCallback, state) { this.timeoutHelper = new TimeoutHelper(timeout); completedSynchronously = true; count = instances.Length; if (count == 0) { Complete(true); return; } for (int index = 0; index < instances.Length; index++) { CallbackState callbackState = new CallbackState(this, instances[index]); IAsyncResult result; try { result = instances[index].BeginCloseInput(this.timeoutHelper.RemainingTime(), nestedCallback, callbackState); } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (Fx.IsFatal(e)) { throw; } Decrement(true, e); continue; } if (result.CompletedSynchronously) { instances[index].EndCloseInput(result); Decrement(true); } } }
protected virtual void onPostPhysicalUpdate() { _mostRecentCallback = CallbackState.PhysicalNeedsUpdate; }