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 1277
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*******@caps tonetechnology. 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*******@caps tonetechnology. 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
language's 30+ year evolution.
What to you think python largest compromises are?
The three that come to my mind are significant whitespace, dynamic
typing, and that it is interpreted - not compiled. These three put
python under fire and cause...
|
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.
"somethread.interrupt()" will wake somethread up when it's in
sleeping/waiting state.
Is there any way of doing this with python's thread? I suppose thread
interrupt is a very primitive functionality for stopping a blocked
thread.
|
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 killed when the import of
the module is complete. Is this expected? Does
python have to be in control to allow threads to run?
Would it be better to arrange things such that the
file is processed using PyRun_SimpleFile?
David S. Harrison
|
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 data-collecting piece of the code runs in a thread.
1. Open the db, and each thread writes the result immediately.
(Sub-question: which is better: cursor object passed to the thread
|
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 and the final process(3) gets
called. what am I doing wrong with the threading? by the way
Directory.GetFiles(IncomingXMLPath1).Length is some global outcome from
process 1.
Thanks
1)
| |
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,
Anthony Nystrom
|
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 process messages coming out of a thread? I want to
queue them up, but MessageQueue doesn't look like what I need. Should I just
make my own queue class? If so I'll have to worry about enumerator
synchronization... a pointer to a 'best practice'...
|
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 this method, I
iniate a PROCESS and on completion, it reduces the available worker
thread and continue.
I have couple of questions;
1. Since I am launching multiple threads on a same method, do I have to
take care of locking so that each one...
|
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 threading. The
instructor is of the opinion that threading is not very useful and
glossed over the subject. At least he admitted that he was glossing
it over. I've noticed that many of the postings on this board have to
do with threading and I...
|
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.
Threading is a new concept for me to implement. Here is my problem.
I have a system that receives xml files and records their file
locations in a database. I can potentially receive thousands,
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |