Mahesh KP
Mahesh KP

Reputation: 6446

Web and windows forms application using same db issues

We have got a web application and a windows forms application. The web application contains a download link to download this forms application.

This forms application will check the client machine privileges and drive space etc. and will update the values to a global database using some webservice calls.

So the web application will continuously checking the global database for the status ie how much checking has been completed by the forms application.

So as soon as the download popup appears for the forms application to download, the web application will start to check the status. But if a user cancels the download or if a user close the forms application, then in these cases how the web application can stop checking for status.

But in my case the web application will always check for the status change , even if the client cancels the download or closes the forms application. So how to avoid this?

Upvotes: 2

Views: 451

Answers (2)

Pasha Immortals
Pasha Immortals

Reputation: 839

You could try to have some thing like a switch as part of a record or some thing in the Database, so the very next time your web app tries to read lets say the bit field it would know that it should stop checking. You could control this bit field as ON & OFF via your forms application. Then your web application you can setup a polling mechnism that checks the db every so often before timing itself off all together based on the bit field or if not been done then aftera period of time.

Having said that your forms application would need to be able to call the outside world where your db is some where located and update it, it can be done many ways, web service call, http, ect...

Update:

I apologies for the delay in replying but did you understand what I said? If your winforms application can call your web service then it can tell it to store a flag field some where like a record in the db for example that your web-application is polling and checking and then by setting that flag field your web-application would know to stop doing any thing with that record, item.

As you mentioned you are worried about:

  • User clicking cancel on download:

In this scenario you would not set the checking of your record by your web-application unless the user has downloaded and run your win-forms application for the first time, so dont start checking upon dowload of the win-forms application but start checking once for the first time the user has opened it, you can do this upon start of the winforms application by setting the flag field from your winforms app by calling your web-service. You will need a polling mechanism on top of this every so often, like a service.

  • When the user closes the winforms application

In this case you would upon termination/close of your winforms app call your web service and set the flag field not to check that record, item any more.

You will need polling in any case as I am thinking you will have many users and hence you will need to monitor the db for incoming messages from your winforms app. Also please be aware as some users are behind firewalls, limited security permissions on their machines and on private networks and your winforms app may not always be able to call your web service.

Hope that helped.

Upvotes: 1

Jonathon Reinhart
Jonathon Reinhart

Reputation: 137468

I think a timeout is your only real option here. Basically the web side will only check for a certain amount of time before giving up. Your status table in your database should include a "last update timestamp" field. If the status is not "complete", and the current time is greater than that timestamp by X seconds, the webserver assumes the process has timed out.

Upvotes: 2

Related Questions