R
rockdale
Hi, All:
If there is a more proper group for multi threads, let me know please.
I have a winform application written in C#.net with the capability to
work offline. If there is a network connection, then the application
will connect to the central database and retrieve data from/save data
into the central database. If there is no network connection, then the
application will save the data to a local xml file.
Here are my questions.
1. Is there an easy way to detect that the network is disconnected.
More specifically, the database is disconnected? Do I need to keep try
to select from a table and wait to the failed result to know it is
disconnected?
2. When the network is broken and the appl tries to connect to the
database, it will take a long time to get the failed connection from
database. the GUI will not respond in this period. I am thinking using
another thread to do all the database work.
3. With another threads doing all the database work, I am from C++
world, in C++ we have postmessage so that we can communicate between
two thread so that the GUI can send a message to the database thread
to retrieve data. And the when the database thread finished retrieve
data, it will send the result back to the GUI thread so the GUI
thread can handle the result. But, in C#, how do we implement this
kind of communication?
I search the internet and some example just have the worker thread
doing some sample work without communicate with the main thread at
all. What I need to know is How the main thread ask the worker thread
to do some task with parameters passed to the worker thread. Once the
worker finished the task, how does the work thread inform the main
thread the work is done and send the result back to main thread to
process.
Any examples /links will be appreciated.
Thanks a lot
-Rockdale
If there is a more proper group for multi threads, let me know please.
I have a winform application written in C#.net with the capability to
work offline. If there is a network connection, then the application
will connect to the central database and retrieve data from/save data
into the central database. If there is no network connection, then the
application will save the data to a local xml file.
Here are my questions.
1. Is there an easy way to detect that the network is disconnected.
More specifically, the database is disconnected? Do I need to keep try
to select from a table and wait to the failed result to know it is
disconnected?
2. When the network is broken and the appl tries to connect to the
database, it will take a long time to get the failed connection from
database. the GUI will not respond in this period. I am thinking using
another thread to do all the database work.
3. With another threads doing all the database work, I am from C++
world, in C++ we have postmessage so that we can communicate between
two thread so that the GUI can send a message to the database thread
to retrieve data. And the when the database thread finished retrieve
data, it will send the result back to the GUI thread so the GUI
thread can handle the result. But, in C#, how do we implement this
kind of communication?
I search the internet and some example just have the worker thread
doing some sample work without communicate with the main thread at
all. What I need to know is How the main thread ask the worker thread
to do some task with parameters passed to the worker thread. Once the
worker finished the task, how does the work thread inform the main
thread the work is done and send the result back to main thread to
process.
Any examples /links will be appreciated.
Thanks a lot
-Rockdale