我有一個IQStreamable
對象,其使用DefineObservable
的Microsoft.ComplexEventProcessing.Application
。StreamInsight:僅當在Task.Run()塊中傳遞X時,才能序列化X類型的值。
該代碼看起來很正常,但我不明白的是,當我使用從Task.Run()
到DefineObservable
的傳入參數時,出現異常。
但是,當我直接使用該屬性,而沒有將它傳遞到Task.Run()
裏面的方法,它的工作。
異常
An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.ComplexEventProcessing.Diagnostics.dll
Additional information: Cannot serialize value of type 'System.IObservable'1[ValueObjects.Price]'.
的方法
private void Monitor(IObservable<Price> priceObservable)
{
const string applicationName = "RealtimeMonitoring";
Microsoft.ComplexEventProcessing.Application application = PriceObserver.Server.CreateApplication(applicationName);
IQStreamable<Price> sStreamable = application
//.DefineObservable<Price>(() => PriceRealtimeProvider.Instance.PriceObservable)
.DefineObservable<Price>(() => PriceObservable)
.ToPointStreamable(=> PointEvent<Price>.CreateInsert(DateTime.Now, price), AdvanceTimeSettings.IncreasingStartTime);
var standingQuery = from p in streamable select price ;
var sink = application.DefineObserver(() => new PriceObserver());
using (standingQuery.Bind(sink).Run())
{
// some code...
}
}
召喚:
Task.Run(()=>Monitor(PriceRealtimeProvider.Instance.PriceObservable)
問:
確實的StreamInsight serialze觀察者對象?爲什麼?
什麼是
這 .DefineObservable<Price>(() => PriceObservable)
和
之間的不同,這 DefineObservable<Price>(() => PriceRealtimeProvider.Instance.PriceObservable)
爲什麼使用arugument引起該問題?