By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,889 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,889 IT Pros & Developers. It's quick & easy.

can you do a global multi-thread "lock", that locks out everything?

P: n/a
I thought I need something like this, but it turns out I don't. I'm
still interested if this can be done:

Can you do a multi-thread "lock", that locks out everything else, all
other threads, without explicitly locking out those other threads?

For example, can you take a single section of code, without changing
any other code at all, and make it so that when it executes, it is the
only thing executing?

Titan

Apr 9 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Titan,

What's the context here? You want to make it the only thread running,
or do you want to make it so that only one thread accesses that code at a
time?

If it is the former, then no, there is no way to do it. Well, you could
code your own solution, but to be honest, that's not exactly an elegant way
of doing anything (to be honest), and I am sure you can achieve what you are
trying to do without doing that.

If you are just trying to prevent other threads from accessing that
block of code at the same time (holding them at bay until a thread exits the
code section) then that's exactly what the lock statement does.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"titan nyquist" <ti***********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
>I thought I need something like this, but it turns out I don't. I'm
still interested if this can be done:

Can you do a multi-thread "lock", that locks out everything else, all
other threads, without explicitly locking out those other threads?

For example, can you take a single section of code, without changing
any other code at all, and make it so that when it executes, it is the
only thing executing?

Titan

Apr 9 '07 #2

P: n/a
I want to make it the only thread running.

I figured there was no way to do it, and I did find a more elegant
solution that did not require it.

I was just curious about it, and I can see it is an ugly way to get
things done.

Thanks,
Titan

Apr 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.