Click here to Skip to main content
15,895,709 members
Home / Discussions / C#
   

C#

 
AnswerRe: is there any free rtf parser component? Pin
Anonymous29-Apr-04 4:51
Anonymous29-Apr-04 4:51 
Questionwhy does this not work? Pin
robmays28-Apr-04 22:19
robmays28-Apr-04 22:19 
AnswerRe: why does this not work? Pin
Corinna John28-Apr-04 22:31
Corinna John28-Apr-04 22:31 
GeneralRe: why does this not work? Pin
robmays28-Apr-04 22:36
robmays28-Apr-04 22:36 
GeneralRe: why does this not work? Pin
robmays28-Apr-04 22:44
robmays28-Apr-04 22:44 
Questionhow can i create a new bitmap file? Pin
lowiq28-Apr-04 20:35
lowiq28-Apr-04 20:35 
AnswerRe: how can i create a new bitmap file? Pin
CWIZO28-Apr-04 20:58
CWIZO28-Apr-04 20:58 
GeneralRe: how can i create a new bitmap file? Pin
lowiq29-Apr-04 3:42
lowiq29-Apr-04 3:42 
AnswerRe: how can i create a new bitmap file? Pin
Heath Stewart29-Apr-04 3:44
protectorHeath Stewart29-Apr-04 3:44 
GeneralPerformance Issues Pin
Member 105947128-Apr-04 19:59
Member 105947128-Apr-04 19:59 
GeneralRe: Performance Issues Pin
Meysam Mahfouzi28-Apr-04 20:39
Meysam Mahfouzi28-Apr-04 20:39 
GeneralRe: Performance Issues Pin
Heath Stewart29-Apr-04 3:40
protectorHeath Stewart29-Apr-04 3:40 
GeneralRe: Performance Issues Pin
Jeff Varszegi29-Apr-04 4:30
professionalJeff Varszegi29-Apr-04 4:30 
GeneralRe: Performance Issues Pin
Heath Stewart29-Apr-04 4:42
protectorHeath Stewart29-Apr-04 4:42 
GeneralRe: Performance Issues Pin
Jeff Varszegi29-Apr-04 4:53
professionalJeff Varszegi29-Apr-04 4:53 
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 

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.