Best practice for multiple items

Feb 12, 2012 at 7:42 AM


I need to create an application that will listen to multiple items from a single server (and get events for changes).

What is the best practice for that? should I create a DdeClient for each item or use single client and call StartAdvise for each item?



Apr 13, 2012 at 12:11 PM

Same Question here,

and can I listen to Multiple instances of the same application?

May 3, 2012 at 1:18 AM

If you have the DLL the following code may help you.  I use it to get FX quote data from MT4.  It also has code for Excel, but it is remarked out.

The text box will display the symbol and the value for each pair as they are updated.

Imports System.Text
Imports NDde.Client

Public Class Form1
    'Private WithEvents client As New DdeClient("Excel", "|C:\Users\Owner\Desktop\vbtest.xls", Me)
        Private WithEvents client As New DdeClient("MT4", "QUOTE", Me)    '--- for mt4


    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            ' Connect to the server.  It must be running or an exception will be thrown.

            ' Advise Loop
            'client.StartAdvise("R8C2", 1, True, 60000) '--- for Excel
            client.StartAdvise("EURUSD", 1, True, 60000)   '--- for mt4
            client.StartAdvise("USDCHF", 1, True, 60000)   '--- for mt4
            client.StartAdvise("USDJPY", 1, True, 60000)   '--- for MT4
        Catch ex As Exception
            displayTextBox.Text = ex.Message
        End Try
    End Sub

    Private Sub client_Advise(ByVal sender As Object, ByVal e As NDde.Client.DdeAdviseEventArgs) Handles client.Advise
        'displayTextBox.Text = "R1C1" + e.Text   '--- for Excel
        displayTextBox.Text = e.Item + " == " + e.Text   '--- for MT4  e.Item gives the pair
            End Sub
    Private Sub client_Disconnected(ByVal sender As Object, ByVal e As NDde.Client.DdeDisconnectedEventArgs) Handles client.Disconnected
        displayTextBox.Text = _
         "OnDisconnected: " + _
         "IsServerInitiated=" + e.IsServerInitiated.ToString() + " " + _
         "IsDisposed=" + e.IsDisposed.ToString()
    End Sub
End Class