473,804 Members | 3,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to wait for a lock for millisecondsTim eout bigger then MaxInt3

Hi,

I wanted to use Monitor.Wait but the millisecondsTim eout parameter is of
type
int, and also with the TimeSpan param it can't be greater than MaxInt32
milliseconds.

What to do ?

Thanks.

Nov 17 '05 #1
6 1845
Hi Yaron,
you must want to wait for a long time, that will give you over 24days of
waiting time :-).

I would recommend that if you want to wait longer you put the call to Wait
inside a loop, the only way to exit the loop is if you acquire the monitor
without timing out (or if the user cancels it), if you do time out the loop
will iterate again calling Monitor.Wait again.

Hope that helps
Mark R Dawson

"yaron" wrote:
Hi,

I wanted to use Monitor.Wait but the millisecondsTim eout parameter is of
type
int, and also with the TimeSpan param it can't be greater than MaxInt32
milliseconds.

What to do ?

Thanks.

Nov 17 '05 #2
> What to do ?

Is that really a problem? You mean you have to wait longer than 25 days?
Mattias

Nov 17 '05 #3
Why would you ever need to hold a lock for more than 28 day's?

Willy.

"yaron" <ya***@discussi ons.microsoft.c om> wrote in message
news:1A******** *************** ***********@mic rosoft.com...
Hi,

I wanted to use Monitor.Wait but the millisecondsTim eout parameter is of
type
int, and also with the TimeSpan param it can't be greater than MaxInt32
milliseconds.

What to do ?

Thanks.

Nov 17 '05 #4
24 day's I meant.

Willy.
"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:OZ******** ******@tk2msftn gp13.phx.gbl...
Why would you ever need to hold a lock for more than 28 day's?

Willy.

"yaron" <ya***@discussi ons.microsoft.c om> wrote in message
news:1A******** *************** ***********@mic rosoft.com...
Hi,

I wanted to use Monitor.Wait but the millisecondsTim eout parameter is of
type
int, and also with the TimeSpan param it can't be greater than MaxInt32
milliseconds.

What to do ?

Thanks.


Nov 17 '05 #5
If ya really want it to be that loooog, a simple subscription service will do
a little better (say a thread wake up every month, check a flag, send some
msg) IMO

Nov 17 '05 #6
You can wait Timeout.Infinit e ( i.e. -1) and wait forever.

--
William Stacey [MVP]

"yaron" <ya***@discussi ons.microsoft.c om> wrote in message
news:1A******** *************** ***********@mic rosoft.com...
Hi,

I wanted to use Monitor.Wait but the millisecondsTim eout parameter is of
type
int, and also with the TimeSpan param it can't be greater than MaxInt32
milliseconds.

What to do ?

Thanks.

Nov 17 '05 #7

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

Similar topics

29
4243
by: Paul L. Du Bois | last post by:
Has anyone written a Queue.Queue replacement that avoids busy-waiting? It doesn't matter if it uses os-specific APIs (eg WaitForMultipleObjects). I did some googling around and haven't found anything so far. Because I know someone will ask: no, the busy-waiting hasn't been a problem in my app. I'm just interested in reading the code. p
4
3579
by: Jeronimo Bertran | last post by:
I have a multithreaded application that manipulates a Queue: protected Queue outputQueue; when I add elements to the queue I use a critical section private void Add(OutputRecord record) { lock(outputQueue) {
9
1717
by: Roger Down | last post by:
Lets say I have a method UpdateCache() called from a single thread. I also have a method GetCache() called from multiple threads. When UpdateCache() is called, the cache updating is being processed. This can take time. In the mean time, some of the multiple threads have called GetCache(), but because the cache is being updated, I want them to wait for the UpdateCache() to finish. Something like this, in a very simplified code:
6
437
by: n_o_s_p_a__m | last post by:
I have seen some debate but am not clear on what the problematic implications of the expression lock(this) are. Microsoft seems to advocate it, but others seem to be against it. Pros and cons? -KJ
12
5278
by: Perecli Manole | last post by:
I am having some strange thread synchronization problems that require me to better understand the intricacies of Monitor.Wait/Pulse. I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock block protecting a resource. Thread 2 and 3 also have a SyncLock block protecting the same resource and after executing some code in their blocks they both do a Monitor.Pulse to hand of the locked resource back to thread 1. While thread 1 has...
3
2075
by: Adam Clauss | last post by:
Documentation states that a call to Wait releases the lock, and will not return until the lock is reacquired. How do exceptions figure into this? Are they considered a form of "return"? Example: lock (someObj) { try
1
2087
by: PaulR | last post by:
Hi all, (DB2 LUW 8.2) I'm just trying to write a little widget to capture lock wait details (when they occur). i.e when a lock-wait occurs, simply record the 2 statements involved in the lock wait. However, I am stumped by the fact that the snapshot monitor does not
1
2189
by: MessyHeart | last post by:
The documentation on MSDN for the overloaded Monitor.wait(object,timespan, bool) is: public static bool Wait( Object obj, TimeSpan timeout, bool exitContext ) Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue. Optionally exits the synchronization domain for the synchronized context before the wait and...
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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,...
0
10575
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, 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...
0
10330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10319
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,...
0
10076
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 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...
0
9144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7616
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.