@@ -247,12 +247,6 @@ void instrRequest_Completed(object sender, InstrumentLookupSubscriptionEventArgs
247
247
this . txtProductType . Text = e . Instrument . Product . Type . ToString ( ) ;
248
248
this . txtContract . Text = e . Instrument . GetFormattedName ( InstrumentNameFormat . User ) ;
249
249
250
- if ( m_instrumentTradeSubscription != null )
251
- {
252
- m_instrumentTradeSubscription . Dispose ( ) ;
253
- m_instrumentTradeSubscription = null ;
254
- }
255
-
256
250
// populate the order feed dropdown
257
251
this . cboOrderFeed . Items . Clear ( ) ;
258
252
foreach ( OrderFeed orderFeed in e . Instrument . GetValidOrderFeeds ( ) )
@@ -261,9 +255,7 @@ void instrRequest_Completed(object sender, InstrumentLookupSubscriptionEventArgs
261
255
this . cboOrderFeed . SelectedIndex = 0 ;
262
256
263
257
// This sample will monitor new orders and deleting working orders
264
- m_instrumentTradeSubscription = new InstrumentTradeSubscription ( m_TTAPI . Session , Dispatcher . Current , e . Instrument ) ;
265
- m_instrumentTradeSubscription . OrderAdded += new EventHandler < OrderAddedEventArgs > ( instrumentTradeSubscription_OrderAdded ) ;
266
- m_instrumentTradeSubscription . OrderDeleted += new EventHandler < OrderDeletedEventArgs > ( instrumentTradeSubscription_OrderDeleted ) ;
258
+ CreateInstrumentTradeSubscription ( e . Instrument ) ;
267
259
m_instrumentTradeSubscription . Start ( ) ;
268
260
}
269
261
catch ( Exception err )
@@ -281,6 +273,19 @@ void instrRequest_Completed(object sender, InstrumentLookupSubscriptionEventArgs
281
273
}
282
274
}
283
275
276
+ private void CreateInstrumentTradeSubscription ( Instrument instrument )
277
+ {
278
+ if ( m_instrumentTradeSubscription != null )
279
+ {
280
+ m_instrumentTradeSubscription . Dispose ( ) ;
281
+ m_instrumentTradeSubscription = null ;
282
+ }
283
+
284
+ m_instrumentTradeSubscription = new InstrumentTradeSubscription ( m_TTAPI . Session , Dispatcher . Current , instrument ) ;
285
+ m_instrumentTradeSubscription . OrderAdded += new EventHandler < OrderAddedEventArgs > ( instrumentTradeSubscription_OrderAdded ) ;
286
+ m_instrumentTradeSubscription . OrderDeleted += new EventHandler < OrderDeletedEventArgs > ( instrumentTradeSubscription_OrderDeleted ) ;
287
+ }
288
+
284
289
#endregion
285
290
286
291
#region InstrumentTradeSubscription Updates
@@ -393,6 +398,8 @@ private void btnApplyOrderFilter_Click(object sender, EventArgs e)
393
398
if ( m_instrumentTradeSubscription == null )
394
399
return ;
395
400
401
+ CreateInstrumentTradeSubscription ( m_instrumentTradeSubscription . Instrument ) ;
402
+
396
403
// no filter to set, return
397
404
if ( this . cboFilter1 . SelectedIndex < 0 )
398
405
return ;
0 commit comments