C++ mft to c#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

translating a project from c++ to c#.

BeginWaitCursor and EndWaitCursor

is lock a good equivalent?

thanks
 
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?
 
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
 
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
 
Back
Top