473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

vb.net Threading Question

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

Nov 21 '05 #1
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
Nov 21 '05 #2
Thanks, but in this case the thread is required.

Nov 21 '05 #3
<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
Nov 21 '05 #4
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
Nov 21 '05 #5
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?

Nov 21 '05 #6
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:

Nov 21 '05 #7
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
Nov 21 '05 #8
<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

Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
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...
19
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....
3
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...
4
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...
6
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...
7
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, ...
4
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...
4
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...
4
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...
19
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.