public static void LoadDataSource(Type dataSourceType, bool autoStart) { try { DataSourceBase ds = Activator.CreateInstance(dataSourceType) as DataSourceBase; if (ds != null) { DispatcherHelper.UIDispatcher.Invoke(new Action(() => { DataSources.Add(ds); })); ds.DataReceived = new Action <string, object>(SendData); ds.DataPointReceived = new Action <DataPoint>(SendData); ds.ExceptionOccurred += DataSource_ExceptionOccurred; ds.Initialize(); if (autoStart) { ds.Start(); } } } catch (Exception ex) { _logService.Error(string.Format("ExistCatch:error:<-{0}->:{1} \r\n Error detail:{2}", "LoadDataSource", ex.Message, ex.ToString())); } }
public static void LoadDataSource(DataSourceBase ds, bool autoStart) { if (ds != null) { DispatcherHelper.UIDispatcher.Invoke(new Action(() => { DataSources.Add(ds); })); ds.DataReceived = new Action <string, object>(SendData); ds.DataPointReceived = new Action <DataPoint>(SendData); ds.ExceptionOccurred += DataSource_ExceptionOccurred; ds.Initialize(); if (autoStart) { ds.Start(); } } }