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