forwardSubscribing to Session Events   Table of ContentAccepting FIX Session Without a Prior Creation of Session Objectforward
Updating GUI Controls on Session Event

Session events are fired from the thread of execution of the OnixS .NET Framework FIX Engine. In order to safely update GUI Controls, it is necessary to use the Control.BeginInvoke method. Otherwise, an application may hang.

Example

The following example demonstrates how to properly update GUI controls from session event handlers.

C#
delegate void UpdateSessionStateDelegate(string state);

void UpdateSessionState(string state)
{
    statusBar.Panels[0].Text = state;
}

void OnStateChange(Object sender, StateChangeEventArgs e)
{
    statusBar.BeginInvoke(
        new UpdateSessionStateDelegate(UpdateSessionState),
        new object[] {e.NewState.ToString()});
}
VB
Dim formStatusBar As StatusBar = New StatusBar

Delegate Sub UpdateSessionStateDelegate(ByVal state As String)

Sub UpdateSessionState(ByVal state As String)
    formStatusBar.Panels.Item(0).Text = state
End Sub


Sub OnStateChange(ByVal sender As Object, ByVal e As StateChangeEventArgs)
    formStatusBar.BeginInvoke( _
        New UpdateSessionStateDelegate(AddressOf Me.UpdateSessionState), _
        New Object() {e.NewState.ToString()})
End Sub