Hello, my question is pretty straight forward and pretty much in the title, but I am expecting that the solution is not. I am making a chat in a windows forms project, and I want the chat to update in real time.
The problem is that I can’t quiet figure out how to make events happening in the database have an effect on my model. I have read up on SignalR, which seems to solve this issue for web applications. The problem is that it’s for a university project, and it seems like SignalR would trivialize a lot of functionality and even remove the need for a lot of the methods I have already made.
Any help is very much appreciated!
It doesn’t work that way. I am assuming that you are having your app “poll” the database for changes. This certainly will work but puts a load on the database as you increase the number of clients. The better approach would be to create a service that connect to the database and then you application connects to the service. This way the service call poll the database and fire events when there are changes.
Ideally, only one service ultimately accesses the actual database and can serve as the event broker to other clients subscribed for events.
No polling required
So like a separate application, as I understand it this is also how the SignalR library works?. The project is more of a proof of concept, so this probably won’t be made, and I will have to have each client poll the server. I guess my question was more along the lines of how I should poll the most efficiently, having a constant connection on a static reader method seems like a huge strain on resources.
You will have to poll your database with your C# code to check for a condition. MySql can’t trigger your C# code.
C# devs
null reference exceptions