Showing posts with label WPF. Show all posts
Showing posts with label WPF. Show all posts

Monday, February 16, 2015

Reactive programming in WPF


http://obtics.codeplex.com

Project Description
The object of this project is to create a library that offers Functional Reactive Programming abilities to common .Net languages.
With FRP your calculations automatically respond to changes in the underlying data. Obtics includes a live Object Linq and Linq to Xml.


Project Description
Continous LINQ is a .NET Framework 3.5 extension that builds on the LINQ query syntax to create continuous, self-updating result sets. 
In traditional LINQ queries, you write your query and get stale results. With Continuous LINQ, 

you write a query and the results of that query are continuously updated as changes are made to the source collection or items within the source collection. 

CLINQ has tremendous value in GUI development and is especially useful in binding to filtered streams of data such as financial or other network message data.

https://rx.codeplex.com

The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. Using Rx, developers represent asynchronous data streams withObservables, query asynchronous data streams using LINQ operators, and parameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, Rx = Observables + LINQ + Schedulers.
Whether you are authoring a traditional desktop or web-based application, you have to deal with asynchronous and event-based programming from time to time. Desktop applications have I/O operations and computationally expensive tasks that might take a long time to complete and potentially block other active threads. Furthermore, handling exceptions, cancellation, and synchronization is difficult and error-prone.
Using Rx, you can represent multiple asynchronous data streams (that come from diverse sources, e.g., stock quote, tweets, computer events, web service requests, etc., and subscribe to the event stream using the IObserver interface. The IObservable interface notifies the subscribed IObserver interface whenever an event occurs.
Because observable sequences are data streams, you can query them using standard LINQ query operators implemented by the Observable extension methods. Thus you can filter, project, aggregate, compose and perform time-based operations on multiple events easily by using these standard LINQ operators. In addition, there are a number of other reactive stream specific operators that allow powerful queries to be written.  Cancellation, exceptions, and synchronization are also handled gracefully by using the extension methods provided by Rx.
Rx complements and interoperates smoothly with both synchronous data streams (IEnumerable) and single-value asynchronous computations (Task).
(currently not supported)

Tuesday, June 26, 2012

Dispatcher and SynchronizationContext classes in WPF

  1. Use the Dispatcher when your code is tightly coupled to WPF. 
  2. Use the AsyncOperationManager when you need to queue something on the 'Context' thread. This works with Windows Forms, ASP .NET and WCF applications as well. 
  3. Avoid using the SynchronizationContext yourself. The AsyncOperationManager uses this mechanism internally. 
Note:

SynchronizationContext.Current object is of type DispatcherSynchronizationContext which is actually just a wrapper around the Dispatcher object and the Post and Send methods just delegate to Dispatcher.BeginInvoke and Dispatcher.Invoke.

So even if you decide to use SynchronizationContext I think you end up calling dispatcher behind the scenes.
Besides, supposedly, it is a bit cumbersome to use SynchronizationContext as you have to pass a reference to the current context to all threads that need to call into your UI.

Thursday, December 3, 2009

Thursday, November 19, 2009

Injection in Unity

Ниже показаны типы Injection в Unity.
Unity выполняет регистрацию соответствия типов и экземпляров объектов.
Кроме этого, он может самостоятельно выполнять создание этих объектов по запросу.
Unity основан на ObjectBuilder, более простом и, на данный момент, устаревшем контейнере.

Injection может быть трех типов:
  1. Construction injection
  2. Property injection
  3. Method call injection
см. рис. ниже.


  • Constructor injection. This type of injection occurs automatically. When you create an instance of an object using the Unity container, it will automatically detect the constructor with the largest number of parameters and execute this, generating instances of each object defined in the constructor parameters. It resolves each parameter type through the container, applying any registrations or mappings for that type. If you want to specify a particular constructor for Unity to use, you can add the InjectionConstructor attribute to that constructor in the target class.
  • Property (setter) injection. This type of injection is optional. You can add the Dependency attribute to any property declarations that you want Unity to resolve through the container. Unity will resolve that property type and set the value of the property to an instance of the resolved type.
  • Method call injection. This type of injection is also optional. You can add the InjectionMethod attribute to any method declarations where you want Unity to resolve the method parameters through the container. Unity will resolve each parameter type and set the value of that parameter to an instance of the resolved type, and then it will execute the method. Method call injection is useful if you need to execute some type of initialization method within the target object.


Конфигурацию типа Injection можно выполнить в файле конфигурации в разделе контейнера, либо читая конфигурацию на запуске, либо динамически ее создавая перед конфигурированием приложения во время выполнения и далее она читается при конфигурировании.
Если в конфигурации не указан тип, который нужно разрешить во время выполнения, тогда Unity просто выполняет инстанцирование этого объекта, просматривая его конструктор. Если конструктор имеет параметры, аналогично, делается попытка найти эти параметры в контейнере. Есть опасность возникновения циклических зависимостей, когда происходит injection двух типов, каждый из которых в качестве параметров конструктора указывает на второй объект.

Wednesday, November 4, 2009

Prism, Composite Application Guidance, CompositeWPF: общие положения

Powered by Blogger.