Solved

c# threading with database

Posted on 2014-03-24
4
278 Views
Last Modified: 2014-04-09
Hi

I have a c#2010 winforms application  connected to an access database

The database is networked, and occasionally when something is updated in the database, then displayed back on screen... the update does not appear to have been actioned because the screen displays the old data, even though the screen has re-queried the database for the fresh data.

Is this just something that I am going to have to live with?  I have tried putting a 3 second delay before re-displaying the data, but even this does not always give enough time..

public void wait(int seconds)
{
    System.Threading.Thread.Sleep(seconds * 1000);
}

Open in new window



my code works as follows:

update the record
wait for 3 seconds
re-query the database and display the results.


so, my question is, does pausing the application like above, also pause the update to the database?
0
Comment
Question by:cycledude
  • 2
4 Comments
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 39949922
I don't think the pause is relevant as in you shouldn't need to do it and it probably won't help.

Unless I am mistaken the update won't return until its complete. So if you're then reading invalid data that makes me think the data has been cached somewhere as opposed to an out of date read.
0
 

Author Comment

by:cycledude
ID: 39949957
Hi Dale

Thanks for the info.

when you say cached, do you mean externally to the application?  I have not implemented any caching in the system (I wouldn't know how to!)
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 39949987
what kind of database? if it's ms access, yes sometimes the db layer does not return the data "updated" immediately.
the only "real" solution is to change the ms access db to some REAL database...
0
 

Author Closing Comment

by:cycledude
ID: 39989806
I guess using a different database will be the best solution... but thats a long termchange
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question