I have a thread that does periodic database maintenance. While this
process is going on I would like the rest of the application to hold
off on accessing the database. I thought I could share a property in a
class to hold the status, but that doesn't seem to work.
Any ideas on what the best way for me to determine when the thread is
doing it's work?
Thanks
Mike 8 1261
Mike, I have a thread that does periodic database maintenance. While this process is going on I would like the rest of the application to hold off on accessing the database. I thought I could share a property in a class to hold the status, but that doesn't seem to work.
Any ideas on what the best way for me to determine when the thread is doing it's work?
Don't use a thread, wait until the process is done.
(You can show a nice wait cursor on your screen)
Cor
Thanks, but in this case the thread is required.
<mm*******@capstonetechnology.com> schrieb I have a thread that does periodic database maintenance. While this process is going on I would like the rest of the application to hold off on accessing the database. I thought I could share a property in a class to hold the status, but that doesn't seem to work.
Any ideas on what the best way for me to determine when the thread is doing it's work?
The simplest thing is probably using Synclock on the Connection object.
Armin
Mike Thanks, but in this case the thread is required.
What are than the things the users should be able to keep on doing while he
cannot get information?
To give us an impression.
Cor
Here is one scenerio.
A thread continually checks the Sql Server to make sure it is available
and is responsive.
This is done so that another part of the app can gather information and
post it to the Sql Server without waiting for connection time out's
etc. The information gathering has to work without interuption. If the
Server is not responsive, then the information gathering saves the
information to a local workstation and will try later to post.
So, if the thread is checking the pulse of the Sql Server, how do I let
the main part of the app know that the pulse is good?
I think I have found my answer in on-line help..
Returning values from procedures that run on separate threads is
complicated by the fact that the procedures cannot be functions and
cannot use ByRef arguments. The best way to return values is to have
your multithreaded procedure call a procedure in your application, and
then pass the results as arguments. To do this, raise an event when a
task is done, and process the results with an event handler.
The following example returns a value by raising an event from a
procedure running on a separate thread:
Mike,
Probably would I set the checks in a Thread with just a global switch that
tells that the server is available or not. In principle does only that
thread change this switch. (However, see the rest)
The only part that the mainthread does than looking at this switch to decide
to save or to update it.
When you start your maintenance you can use another switch that prevents
this process to change the first switch and set this first switch (therefore
it has on both places to be synclocked).
While the maintenance switch is busy the first switch is not updated by the
checking thread (it even can be aborted).
Probably I would use two switches to stop the checking thread as well.
If I wrote something wrong it is more the idea.
Just my thought,
Cor
<mm*******@capstonetechnology.com> schrieb I think I have found my answer in on-line help..
Returning values from procedures that run on separate threads is complicated by the fact that the procedures cannot be functions and cannot use ByRef arguments. The best way to return values is to have your multithreaded procedure call a procedure in your application, and then pass the results as arguments. To do this, raise an event when a task is done, and process the results with an event handler.
The following example returns a value by raising an event from a procedure running on a separate thread:
I thought it was a synchronization problem, not a
how-to-return-results-from-a-thread problem.
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Anthony_Barker |
last post by:
I have been reading a book about the evolution of the Basic
programming language. The author states that Basic - particularly
Microsoft's version is full of compromises which crept in along the...
|
by: Jane Austine |
last post by:
As far as I know python's threading module models after Java's.
However, I can't find something equivalent to Java's interrupt and
isInterrupted methods, along with InterruptedException....
|
by: David Harrison |
last post by:
I am working on an application on Mac OS X that calls out
to python via PyImport_ImportModule(). I find that if
the imported module creates and starts a python thread,
the thread seems to be...
|
by: Antal Rutz |
last post by:
Hi, All!
I'm new to threading. I have some design questions:
Task: I collect data and store them in an RDBMS (mysql or pgsql)
The question is how to do that with threading?
The...
|
by: CK |
last post by:
I have the following code in a windows service, when I start the windows
service process1 and process2 work fine , but final process (3) doesnt get
called. i stop and restart the windows service...
|
by: Anthony Nystrom |
last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up
again... Just curious... If the thread is enabling a form, if the form is
disposed is the thread as well?
Thanks,
...
|
by: Bob |
last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done?
- It is OK to pass objects out of the thread? (dumb question maybe but I
want to be sure)
- What's the best way to...
|
by: DBC User |
last post by:
I have a background process which reads a table to see if there are any
pending requests. If there are any, then it will start a worker thread
(only 10 allowed at a time) and executes a method. In...
|
by: Steven |
last post by:
I am taking an "advanced" VB.Net course via web at a state university
toward an information science degree. This is my second VB class and
I am kind of disappointed in it. This week we covered...
|
by: frankiespark |
last post by:
Hello all,
I was perusing the internet for information on threading when I came
across this group. Since there seems to be a lot of good ideas and
useful info I thought I'd pose a question.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |