public void HandleExecutionReport(QuickFix.FIX44.ExecutionReport msg) { try { string execId = msg.ExecID.Obj; //string transType = FixEnumTranslator.Translate(msg.ExecType); string execType = FixEnumTranslator.Translate(msg.ExecType); Trace.WriteLine("EVM: Handling ExecutionReport: " + execId + " / " + execType); ExecutionRecord exRec = new ExecutionRecord( msg.ExecID.Obj, msg.OrderID.Obj, string.Empty, execType, msg.Symbol.Obj, FixEnumTranslator.Translate(msg.Side)); exRec.LeavesQty = msg.LeavesQty.getValue(); exRec.TotalFilledQty = msg.CumQty.getValue(); exRec.LastQty = msg.LastQty.getValue(); SmartDispatcher.Invoke(new Action <ExecutionRecord>(AddExecution), exRec); } catch (Exception e) { Trace.WriteLine(e.ToString()); } }
private void Save(object arg) { if (Template.IsChanged) { IsBusy = true; try { var service = serviceLocator.GetInstance <ITrainingSetTemplateService>(); service.TrainingSetTemplateSaved += (sender, e) => { switch (e.Value.Status) { case SaveTemplateStatus.Success: if (ApplicationUser.CurrentUser.Templates.Contains(e.Value.SavedTemplate)) { SmartDispatcher.BeginInvoke(() => { var list = ApplicationUser.CurrentUser.Templates as ObservableCollection <TrainingSetTemplate>; var index = list.IndexOf(e.Value.SavedTemplate); list.RemoveAt(index); list.Insert(index, e.Value.SavedTemplate); shell.RemoveFromLayoutRoot(View as UIElement); }); } else { SmartDispatcher.BeginInvoke(() => { ApplicationUser.CurrentUser.Templates.Add(e.Value.SavedTemplate); shell.RemoveFromLayoutRoot(View as UIElement); }); } break; case SaveTemplateStatus.Error: dialogFacade.Alert(MyLibraryResources.ErrorSavingTemplate); break; default: break; } IsBusy = false; }; service.TrainingSetTemplateSaveError += (sender, e) => { IsBusy = false; }; service.SaveTemplate(Template); } catch (Exception ex) { dialogFacade.Alert(MyLibraryResources.ErrorSavingTemplate); IsBusy = false; } } else { shell.RemoveFromLayoutRoot(View as UIElement); } }
public void LoadTelemetry(ICollection <Telemetry> telemetry) { SmartDispatcher.BeginInvoke(() => { this.profileChart.LoadTelemetry(telemetry); }); }
private void LoadTextAnimation(FrameworkElement animation, TimeSpan duration) { Grid.SetColumnSpan(animation, 3); Grid.SetRowSpan(animation, 3); animation.HorizontalAlignment = HorizontalAlignment.Center; animation.VerticalAlignment = VerticalAlignment.Center; animation.Visibility = Visibility.Visible; playerGrid.Children.Add(animation); var startAnimation = animation.Resources["InTransition"] as Storyboard; if (startAnimation != null) { startAnimation.Begin(); ThreadPool.QueueUserWorkItem((_animation) => { Thread.Sleep(Convert.ToInt32(duration.TotalMilliseconds)); SmartDispatcher.BeginInvoke(() => { var stopAnimation = animation.Resources["OutTransition"] as Storyboard; stopAnimation.Begin(); playerGrid.Children.Remove(animation); }); }, animation); } }
public void HandleExecutionReport(QuickFix.FIX42.ExecutionReport msg) { try { string execId = msg.ExecID.Obj; string transType = FixEnumTranslator.Translate(msg.ExecTransType); string execType = FixEnumTranslator.Translate(msg.ExecType); Trace.WriteLine("EVM: Handling ExecutionReport: " + execId + " / " + transType + " / " + execType); ExecutionRecord exRec = new ExecutionRecord( msg.ExecID.Obj, msg.OrderID.Obj, transType, execType, msg.Symbol.Obj, FixEnumTranslator.Translate(msg.Side)); SmartDispatcher.Invoke(new Action <ExecutionRecord>(AddExecution), exRec); } catch (Exception e) { Trace.WriteLine(e.ToString()); } }
private void mnuAbout_Click(object sender, EventArgs e) { SmartDispatcher.BeginInvoke(() => { NavigationService.Navigate(new Uri("/YourLastAboutDialog;component/AboutPage.xaml", UriKind.Relative)); }); }
public void RaiseCanExecuteChanged() { if (CanExecuteChanged != null) { SmartDispatcher.BeginInvoke(() => CanExecuteChanged(this, new EventArgs())); } }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are being GPU accelerated with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; } // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); SmartDispatcher.Initialize(Deployment.Current.Dispatcher); }
protected override void OnNavigatedTo(NavigationEventArgs e) { SmartDispatcher.BeginInvoke(() => { if (ApplicationBar == null) { BuildApplicationBar(); } else { ApplicationBar.IsVisible = true; } }); SmartDispatcher.BeginInvoke(() => { var postalCode = NavigationContext.TryGetKey("PostalCode"); var country = NavigationContext.TryGetStringKey("Country"); if (postalCode.HasValue && string.IsNullOrEmpty(country) == false) { ViewModel.LoadCity(postalCode.Value, country); } }); base.OnNavigatedTo(e); }
void ReadCallback(IAsyncResult asynchronousResult) { try { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); ImageCacheService.SaveImage(response.GetResponseStream()); } catch (Exception e) { SmartDispatcher.BeginInvoke(delegate { if (ReadError != null) { ReadError(this, null); } }); } SmartDispatcher.BeginInvoke(delegate { if (ReadFinished != null) { ReadFinished(this, null); } }); }
private void ViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) { if (propertyChangedEventArgs.PropertyName == "IsSearchBoxVisible") { Scheduler.Default.Schedule(TimeSpan.FromMilliseconds(200), () => SmartDispatcher.BeginInvoke(SetFocus)); } }
private void ItemClicked(object s, EventArgs ea) { SystemMessageItemControl c = s as SystemMessageItemControl; currentSelectedNumber = (int)c.Tag; SmartDispatcher.BeginInvoke(UpdateCurrentMessageText); }
private void UpdateAppBar() { SmartDispatcher.BeginInvoke(() => { switch (FavoritedState) { case FavoritedState.Unknown: break; case FavoritedState.Me: AppbarButtons.Remove(_favoriteAppbarButton); AppbarButtons.Remove(_unfavoriteAppbarButton); break; case FavoritedState.Favorited: AppbarButtons.Remove(_favoriteAppbarButton); AppbarButtons.Add(_unfavoriteAppbarButton); break; case FavoritedState.NotFavorited: AppbarButtons.Remove(_unfavoriteAppbarButton); AppbarButtons.Add(_favoriteAppbarButton); break; default: throw new ArgumentOutOfRangeException(); } }); }
/// <summary> /// Notify any listeners that the property value has changed. /// </summary> /// <param name="propertyName">The property name.</param> protected void NotifyPropertyChanged(string propertyName) { if (string.IsNullOrEmpty(propertyName)) { throw new ArgumentException("PropertyName cannot be empty or null."); } PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { PropertyChangedEventArgs args; if (!_argumentInstances.TryGetValue(propertyName, out args)) { args = new PropertyChangedEventArgs(propertyName); _argumentInstances[propertyName] = args; } // Fire the change event. The smart dispatcher will directly // invoke the handler if this change happened on the UI thread, // otherwise it is sent to the proper dispatcher. SmartDispatcher.BeginInvoke(delegate { handler(this, args); }); } }
private void RefreshIsActive() { if (!_refreshPending) { _refreshPending = true; SmartDispatcher.RunAsync(DoRefresh); } }
private void DisplayEmptyView() { SmartDispatcher.BeginInvoke(() => { stackPanelMessageItems.Children.Clear(); textBlockMessageText.Text = String.Empty; }); }
private void NavigateInternal(Uri path) { SmartDispatcher.BeginInvoke(() => { Debug.WriteLine("NavigationService::Navigating to {0}", path); PlatformNavigationService.Navigate(path); }); }
public App() { this.Startup += this.Application_Startup; this.Exit += this.Application_Exit; this.UnhandledException += this.Application_UnhandledException; SmartDispatcher.Initialize(Deployment.Current.Dispatcher); InitializeComponent(); }
protected virtual void RaisePropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { SmartDispatcher.BeginInvoke(() => handler(this, new PropertyChangedEventArgs(propertyName))); } }
private void PivotLayout_SelectionChanged(object sender, SelectionChangedEventArgs e) { SmartDispatcher.BeginInvoke(() => { if (ApplicationBar != null && (this.Orientation & PageOrientation.Landscape) != PageOrientation.Landscape) { ApplicationBar.IsVisible = (PivotLayout.SelectedItem == WeatherPivotItem); } }); }
private void UpdateTelemetryAt(object arg) { SmartDispatcher.BeginInvoke(() => { if (queue.Any() && queue.Peek().TimePosition <= PlayerPosition) { CurrentTelemetry = queue.Dequeue(); } }); }
internal void NotifyPropertyChanged(String propertyName) { SmartDispatcher.BeginInvoke(() => { PropertyChangedEventHandler handler = _PropertyChanged; if (null != handler) { handler(this, new PropertyChangedEventArgs(propertyName)); } }); }
private void CheckForTextToDisplayAt(object arg) { SmartDispatcher.BeginInvoke(() => { if (textQueue.Count > 0 && textQueue.Peek().StartTime <= PlayerPosition) { LoadVideoText(textQueue.Dequeue()); //SmartDispatcher.BeginInvoke(() => LoadVideoText(textQueue.Dequeue())); } }); }
public void InitialiseViewModel() { var igWebApiConnectionConfig = ConfigurationManager.GetSection("IgWebApiConnection") as NameValueCollection; var env = igWebApiConnectionConfig["environment"]; var smartDispatcher = (SmartDispatcher)SmartDispatcher.GetInstance(); smartDispatcher.SetViewModel(ApplicationViewModel.getInstance()); IgRestApiClient = new IgRestApiClient(env, igWebApiConnectionConfig["account"], smartDispatcher); }
void _accelerometer_CurrentValueChanged(object sender, SensorReadingEventArgs <AccelerometerReading> e) { var position = e.SensorReading.Acceleration; SmartDispatcher.Dispatch(() => { this.XValue = position.X.ToString("0.0000"); this.YValue = position.Y.ToString("0.0000"); this.ZValue = position.Z.ToString("0.0000"); }); }
private void OnLogout() { // Clear all the orders, we'll get a new list when we reconnect lock (_marketLock) { _market.Clear(); } lock (_stackLock) { SmartDispatcher.Invoke(() => OrderStack.Clear()); } }
public void InitialiseViewModel() { var igWebApiConnectionConfig = ConfigurationManager.GetSection("IgWebApiConnection") as NameValueCollection; string env = igWebApiConnectionConfig["environment"]; SmartDispatcher smartDispatcher = (SmartDispatcher)SmartDispatcher.getInstance(); smartDispatcher.setViewModel(ApplicationViewModel.getInstance()); igRestApiClient = new IgRestApiClient(env, smartDispatcher); igStreamApiClient = new IGStreamingApiClient(); }
private void InitializePhoneApplication() { if (phoneApplicationInitialized) return; RootFrame = new TransitionFrame(); RootFrame.Navigated += CompleteInitializePhoneApplication; RootFrame.NavigationFailed += RootFrame_NavigationFailed; SmartDispatcher.Initialize(Deployment.Current.Dispatcher); phoneApplicationInitialized = true; }
public void HandleMessage(QuickFix.Message msg, bool isIncoming) { try { MessageRecord mr = new MessageRecord(msg, isIncoming); SmartDispatcher.Invoke(new Action <MessageRecord>(AddMessage), mr); } catch (Exception e) { Trace.WriteLine(e.ToString()); } }
void ReadCallback(IAsyncResult asynchronousResult) { try { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream())) { string resultString = streamReader1.ReadToEnd(); System.Xml.Linq.XElement MyXElement = System.Xml.Linq.XElement.Parse(resultString); DataModel = new RijksDataModel { Exension = MyXElement.Element("config").Elements("image").Attributes("extension").First().Value, Path = MyXElement.Element("config").Elements("image").Attributes("path").First().Value, ArtistId = MyXElement.Element("artobject").Elements("artist").Attributes("id").First().Value, ArtistName = MyXElement.Element("artobject").Elements("artist").First().Value, CreationDate = MyXElement.Element("artobject").Elements("creationdate").Attributes("value").First().Value, Description = MyXElement.Element("artobject").Elements("description").First().Value, Link = MyXElement.Element("artobject").Elements("link").Attributes("href").First().Value, ObjectId = MyXElement.Element("artobject").Attributes("id").First().Value, Title = MyXElement.Element("artobject").Elements("title").First().Value.ToLower(), ReadDate = DateTime.Now }; DataModel.Description = DataModel.Description.Replace("\r", string.Empty).Replace("\n", string.Empty); } } catch (Exception e) { SmartDispatcher.BeginInvoke(delegate { if (ReadError != null) { ReadError(this, null); } }); } SmartDispatcher.BeginInvoke(delegate { if (ReadFinished != null) { ReadFinished(this.DataModel); } }); }
static void Main(string[] args) { var d = new Dispatcher(); var midgetHouse = new MidgetHouse(d); d.Subscribe<OrderPlaced>(midgetHouse); d.Subscribe<DodgyOrderPlaced>(midgetHouse); var manager = new Manager(); var cashier = new Cashier(d); var ass = new AssMan(d); var cookDispatcher = new SmartDispatcher<CookFood>(); var cookTtlGate = new TimeToLiveGate<CookFood>(cookDispatcher); var cookQueudHandler = new QueuedHandler<CookFood>(cookTtlGate, "cook ttl gate"); var cookLimiter = new Limiter<CookFood>(cookQueudHandler); //var cookScrewsUp = new ScrewsUp<CookFood>(cookLimiter); var alarmClock = new AlarmClock(d); var messageMonitor = new MessageMonitor(d); var fmm = new FilePerOrderMonitor(d); d.Subscribe(alarmClock); d.Subscribe(cookLimiter); d.Subscribe(ass); d.Subscribe(cashier); d.Subscribe(manager); d.Subscribe<OrderPlaced>(messageMonitor); d.Subscribe<DodgyOrderPlaced>(messageMonitor); d.Subscribe<OrderPlaced>(fmm); d.Subscribe<DodgyOrderPlaced>(fmm); var cookQueudHandler1 = new QueuedHandler<CookFood>(new Cook(d, 10000), "c1"); cookDispatcher.AddHandler(cookQueudHandler1); var cookQueudHandler2 = new QueuedHandler<CookFood>(new Cook(d, 5000), "c2"); cookDispatcher.AddHandler(cookQueudHandler2); var cookQueudHandler3 = new QueuedHandler<CookFood>(new Cook(d, 100), "c3"); cookDispatcher.AddHandler(cookQueudHandler3); var queueMonitor = new QueueMonitor(new IAmMonitored[] {cookQueudHandler1, cookQueudHandler2, cookQueudHandler3, cookQueudHandler,d.QueudHandler}); //Cook cook = new Cook(ass); var waiter = new Waiter(d); cookQueudHandler1.Start(); cookQueudHandler2.Start(); cookQueudHandler3.Start(); cookQueudHandler.Start(); d.Start(); alarmClock.Start(); queueMonitor.Start(); new Thread(TryPay).Start(cashier); Random r = new Random(); for (int i = 0; i < 500; i++) { Guid orderNumber; if (r.Next()%2 == 0) { orderNumber = waiter.PlaceDodgyOrder(new[] {Tuple.Create("Burger", 1)}, 15); } else { orderNumber = waiter.PlaceOrder(new[] { Tuple.Create("Burger", 1) }, 15); } if(i > 2)Thread.Sleep(2000); orders.TryAdd(orderNumber, null); } //var orderNumber = waiter.PlaceOrder(new[] {Tuple.Create("Burger", 1)}, 15); //cashier.PayForOrder(orderNumber); Console.ReadLine(); }