C++ mft to c#

G

Guest

translating a project from c++ to c#.

BeginWaitCursor and EndWaitCursor

is lock a good equivalent?

thanks
 
N

Nicholas Paldino [.NET/C# MVP]

BeginWaitCursor and EndWaitCursor are used to display an hourglass
cursor. lock is used to synchronize access to a resource from multiple
accesses across threads. They are not related.

What are you trying to do?
 
G

Guest

my c++ code;
----------------
BeginWaitCursor();
if (test1)
//do stuff
else if (test2)
//then do this stuff
EndWaitCursor();

but if all i'm doing is showing an hourglass i can simply use the cursor
class?


Nicholas Paldino said:
BeginWaitCursor and EndWaitCursor are used to display an hourglass
cursor. lock is used to synchronize access to a resource from multiple
accesses across threads. They are not related.

What are you trying to do?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mgonzales3 said:
translating a project from c++ to c#.

BeginWaitCursor and EndWaitCursor

is lock a good equivalent?

thanks
 
A

Andy Bates

Try:

Cursor.Current = Cursors.WaitCursor;

try
{
// Put your processing here.
if (test1)...
}
finally
{
Cursor.Current = Cursors.Default;
}

lock will serialise access to the contained code over multiple threads of
execution; probably not what you require in this instance.

The finally block above ensures that if any exceptions are thrown that the
cursor is restored to the default.

mgonzales3 said:
my c++ code;
----------------
BeginWaitCursor();
if (test1)
//do stuff
else if (test2)
//then do this stuff
EndWaitCursor();

but if all i'm doing is showing an hourglass i can simply use the cursor
class?


Nicholas Paldino said:
BeginWaitCursor and EndWaitCursor are used to display an hourglass
cursor. lock is used to synchronize access to a resource from multiple
accesses across threads. They are not related.

What are you trying to do?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mgonzales3 said:
translating a project from c++ to c#.

BeginWaitCursor and EndWaitCursor

is lock a good equivalent?

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top