Is it possible to reload a form of the running application from one computer when I executed a function from my other computer with the same application? co'z I want to see the changes of data on my datagrid view

Dani AI

Generated

As suggested, you do not need a manual refresh button — you can have one instance tell the other to reload. For a LAN app written in VB2008 the common, practical choices are: quick polling (timer that re-queries the DB), push-notify via LAN messages (UDP/TCP), or database-driven notifications (SqlDependency/Query Notifications if you use SQL Server). Each has tradeoffs: polling is simple but has latency and load; push is low-latency but needs network/firewall setup; SqlDependency is reliable for SQL Server but requires Service Broker enabled.

For a small LAN the simplest push approach is a tiny UDP “REFRESH” broadcast from the machine that changed data and a UdpClient listener in each running instance that invokes the UI reload on receipt. Example skeletons (trim to fit your project):

' listener (start on Form_Load)
Dim udp As New System.Net.Sockets.UdpClient(4032)
udp.BeginReceive(AddressOf OnReceive, udp)

Private Sub OnReceive(ar As IAsyncResult)
    Dim u = CType(ar.AsyncState, System.Net.Sockets.UdpClient)
    Dim ep As System.Net.IPEndPoint = Nothing
    Dim data() As Byte = u.EndReceive(ar, ep)
    Dim msg = System.Text.Encoding.UTF8.GetString(data)
    If msg = "REFRESH" Then
        Me.BeginInvoke(New MethodInvoker(AddressOf ReloadGrid))
    End If
    u.BeginReceive(AddressOf OnReceive, u)
End Sub
' sender (call when data changes)
Using u As New System.Net.Sockets.UdpClient()
    u.EnableBroadcast = True
    Dim b = System.Text.Encoding.UTF8.GetBytes("REFRESH")
    u.Send(b, b.Length, New System.Net.IPEndPoint(System.Net.IPAddress.Broadcast, 4032))
End Using

Important notes: update the DataGridView only on the UI thread (Invoke/BeginInvoke), pick a fixed port and open it in firewalls, and remember UDP is unreliable (use periodic polling fallback or switch to TCP/WCF if you need guaranteed delivery and authentication). If the app uses SQL Server, investigate SqlDependency for push-style DB notifications instead.

Recommended Answers

All 2 Replies

Yes you can try socket...

Make a connection between two application(Two application means a application running on two different computer....)..

Now when one application perform some task just send a command to refresh to other application, and in other application just refresh it...

Yes you can try socket...

Make a connection between two application(Two application means a application running on two different computer....)..

Now when one application perform some task just send a command to refresh to other application, and in other application just refresh it...

okay I'll just put a refresh button for my grid

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.