开发者

how to create a popup window in C#.net

I have two different applications on different system.If a 开发者_JAVA百科button pressed in one application i keep its record in Database and according to the record I want to popup a window in second application that notifying that Button is pressed in first application.

How could I do this? Is it feasible?


Since you are storing a record in the database, you can poll the database from second application and take the action based on the state. Once the request has been addressed, you can mark the record in the database.


You said different systems (i.e. computers). right?
In that case you would have to send some sort of message to the other application to initiate a popup.

Is the Database you are storing the value accessible by both Computers ?
In that case if a little delay (few seconds) is acceptable between pressing a button in an app on one computer and the popup on the other, you could also use some sort of polling. So the other system where the popup would show, can check the database at regular intervals (say every 10 seconds) for the record that is set by the Button press and if present then show the popup.

But if such a delay is not acceptable, then you would need to use some networking between the two applications. So a message can be sent directly to the popup generating application from the button one.

Update
Yes you will need a continuously running exe on the other (popup) system for either of solutions, be it database polling or networking.

For Database Polling :

  • Simply create a windows application.
  • Add a timer object to it with an interval of as many milliseconds you want between polls (for 10 seconds set it to 10000)
  • Then write database retrieval code in the Tick event Handler for the timer control.

For Networking: Take a look at following question - networking in .net/C#


If you're using SQL Server as your database you may be able to use SQL Server Query Notifications

This discussion is similar... Notification about Database Change


Instead of using polling from the 2nd app, you can be notified when the table changes. You can use a class called SqlDependency for this. A good example can be seen on codeproject. In fact, the example sounds very close to what you're looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜