Solved

c# threading with database

Posted on 2014-03-24
4
274 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 142

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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 gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now