Solved

c# threading with database

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

772 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