0

I am new to c# programming. Currently I am working on kinect application. I have read about the WPF architecture and Binding data to the controls. But in my application, It should insert the user Details automatically to the local databse when it detects that user has absent for few minutes.

So, I have created a database using SQL Server. I have written a condition that when it should establish a Connection & insert a row to the database. But it is not working parallely. when it reaches to specific time, The GUI is not responding. Could someone tell me the way i should proceed?

1 Answers1

0

Your ui can only work in the (unique) ui thread, and all the ui updates must also be done on ui thread.

If you don't want to block the ui, you must execute your task in another thread. The best practice, if you're working in fw4, is to use await async.

Here is an sample.

Community
  • 1
  • 1
Eric Bole-Feysot
  • 13,949
  • 7
  • 47
  • 53
  • thanks for the Explanation. But i am confused about Backroundworker & await async. What is the best solution for Database query? – user3792685 Jan 30 '15 at 15:02
  • I would go with await async. It is the more up to date feature to do background tasks. What you do in tasks doesn't matter. – Eric Bole-Feysot Feb 02 '15 at 07:03