我有一个IQStreamable
使用.DefineObservable
Microsoft.ComplexEventProcessing.Application
代码看起来很正常,但我不明白的是,当我使用Task.Run()
into传入的参数时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 是否序列化观察者对象?为什么?
之间有什么不同
这
.DefineObservable<Price>(() => PriceObservable)
和
这个
DefineObservable<Price>(() => PriceRealtimeProvider.Instance.PriceObservable)
为什么使用参数会导致问题?