Messaging in Windows forms

Hi there all!

I'm a newbie to this forum, my first question is I'm building a windows app where I want the user to be able to fill out a form and click a button and have the forms contents saved on sql server and instantly received by any other user logged into the same app. Similar to an alert message. Any ideas on the best way to do this  Can I trigger a message box or something when there is an update in sql

Any help would be great!

Thanks!


Answer this question

Messaging in Windows forms

  • Jason Wells

    There are numerous ways to handle this. None of which are easy to implement. It depends upon what you mean by "instantly". If you require the updates to be reflected within 1 second, you should probably code a 3 tiered application.  Run all your updates through a middle tier that is constantly connected to all running clients (TCP/IP sockets). It could instantly push all updates to every client.

    If your updates can be delayed, you can easily code a simple polling scheme. I have used this in the past and it has worked well.  Just create a table the logs the last datetime of a change. Every so often (I use 60 seconds), have your program go look and see if the datetime has changed. If there is a change then grab the updates. This is a really quick search that shouldn't noticeable impact the server load (I have never tested past 100 users). You can easily add a feature to allow the user to force a check (F5 refresh).

    You can also embark on the new notification services available in MS SQL.  http://www.codeproject.com/dotnet/SQLNS.asp




  • popson

    And if you need an enterprise-class solution, you can look at Microsoft Message Queue (MSMQ). Or you can use remoting. But pretty much any solution is going to require some kind of polling as Mike pointed out. You can either do it yourself or use one of the other technologies, if it fits your application and network.

    Don

  • Messaging in Windows forms