Click here to Skip to main content
15,887,248 members
Home / Discussions / C#
   

C#

 
GeneralA question about TabletPC SDK Pin
Member 94012528-Apr-04 18:45
Member 94012528-Apr-04 18:45 
GeneralRe: A question about TabletPC SDK Pin
Heath Stewart29-Apr-04 3:38
protectorHeath Stewart29-Apr-04 3:38 
GeneralDeloyment Question Pin
Larry J. Siddens28-Apr-04 16:19
Larry J. Siddens28-Apr-04 16:19 
GeneralRe: Deloyment Question Pin
Tarakeshwar28-Apr-04 18:27
Tarakeshwar28-Apr-04 18:27 
GeneralRe: Deloyment Question Pin
Heath Stewart29-Apr-04 3:32
protectorHeath Stewart29-Apr-04 3:32 
GeneralRe: Deloyment Question Pin
Heath Stewart29-Apr-04 3:37
protectorHeath Stewart29-Apr-04 3:37 
GeneralSelfish LOCK! Pin
CiVerDream28-Apr-04 14:20
CiVerDream28-Apr-04 14:20 
GeneralRe: Selfish LOCK! Pin
Jeff Varszegi28-Apr-04 14:52
professionalJeff Varszegi28-Apr-04 14:52 
I would like to limit the amount of seconds that the higher priority is waiting for the lock before trying to force the lower priority task to forget about the lock

using System.Threading;
// ...
bool isLockAcquired = Monitor.TryEnter(yourLockedObject, maximumMillisecondsToWait);

if (!isLockAcquired) {
   // Go about forcing the issue, in whatever way most appeals to you
}


You have to be careful to release the lock if it's successfully acquired, but only then. The Microsoft .NET implementation will silently ignore requests to release an unheld lock, but Mono chokes on this; in this case, the Microsoft implementation is actually against the specified behavior! You should want to write code that's correct, anyhow. Be careful whenever you use Monitor.Enter() and Monitor.Exit(); you can introduce subtle bugs that are easily avoided by using lock (obj) {}.

As for the polling, there's no help for it; it's better than forcing an abortion. Why the desire for avoidance? It's not expensive in the grand scheme of things to check a variable once in a while.

Regards,

Jeff Varszegi

EEEP!
GeneralRe: Selfish LOCK! Pin
Heath Stewart29-Apr-04 3:32
protectorHeath Stewart29-Apr-04 3:32 
GeneralRe: Selfish LOCK! Pin
scadaguy28-Apr-04 15:37
scadaguy28-Apr-04 15:37 
Generalcrystal report export to excel Pin
econnor28-Apr-04 11:58
econnor28-Apr-04 11:58 
GeneralRe: crystal report export to excel Pin
Heath Stewart28-Apr-04 12:47
protectorHeath Stewart28-Apr-04 12:47 
GeneralAbout ArrayList. Help! Pin
wk_vigorous28-Apr-04 11:52
wk_vigorous28-Apr-04 11:52 
GeneralRe: About ArrayList. Help! Pin
Christian Graus28-Apr-04 12:00
protectorChristian Graus28-Apr-04 12:00 
GeneralRe: About ArrayList. Help! Pin
Colin Angus Mackay28-Apr-04 12:29
Colin Angus Mackay28-Apr-04 12:29 
GeneralRe: About ArrayList. Help! Pin
Jeff Varszegi28-Apr-04 12:44
professionalJeff Varszegi28-Apr-04 12:44 
GeneralRe: About ArrayList. Help! Pin
wk_vigorous29-Apr-04 0:43
wk_vigorous29-Apr-04 0:43 
GeneralRe: About ArrayList. Help! Pin
Jeff Varszegi29-Apr-04 2:56
professionalJeff Varszegi29-Apr-04 2:56 
Generaladding a dataset to a database Pin
(Steven Hicks)n+128-Apr-04 11:16
(Steven Hicks)n+128-Apr-04 11:16 
GeneralRe: adding a dataset to a database Pin
Heath Stewart28-Apr-04 11:26
protectorHeath Stewart28-Apr-04 11:26 
GeneralFree Form Controls Pin
Jon G28-Apr-04 9:58
Jon G28-Apr-04 9:58 
GeneralRe: Free Form Controls Pin
Heath Stewart28-Apr-04 10:01
protectorHeath Stewart28-Apr-04 10:01 
GeneralRe: Free Form Controls Pin
Jon G28-Apr-04 10:08
Jon G28-Apr-04 10:08 
GeneralRe: Free Form Controls Pin
Jon G28-Apr-04 10:14
Jon G28-Apr-04 10:14 
GeneralRe: Free Form Controls Pin
Heath Stewart28-Apr-04 10:15
protectorHeath Stewart28-Apr-04 10:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.