> Is there something similar for C++/CLI ?.
>
> VOID WINAPI Sleep(DWORD dwMilliseconds);
>
> I need to stop the execution between processes during a time.
Will Thread.Sleep() do it for you:
http://msdn2.microsoft.com/en-us/library/aa332371(vs.71).aspx
You know that if the native Sleep() is really what you want that you can
P/Invoke it, right?
Just by the way, you are not planning to stall a thread that manages UI
elements are you?
Regards,
Will
www.ivrforbeginners.com
Ben Voigt - 12 Apr 2007 14:16 GMT
>> Is there something similar for C++/CLI ?.
>>
[quoted text clipped - 8 lines]
> You know that if the native Sleep() is really what you want that you can
> P/Invoke it, right?
With C++/CLI, you can directly call native functions without using P/Invoke.
> Just by the way, you are not planning to stall a thread that manages UI
> elements are you?
>
> Regards,
> Will
> www.ivrforbeginners.com
>Is there something similar for C++/CLI ?.
The System::Threading::Thread class has a Sleep method.
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Simplified, I need to do this:
private: NameSpace::SpecialClass^ m_pSpecialClass;
private: System::Void button_Click(System::Object^ sender,
System::EventArgs^ e) {
if ( m_pSpecialClass->FunctionA() == false )
return;
Sleep(3000);
if ( m_pSpecialClass->FunctionB() == false )
return;
Sleep(3000);
if ( m_pSpecialClass->FunctionC() == false )
return;
Sleep(3000);
this->Close();
}
I need a stop between the functions and before to close de Form.

Signature
Tomas
Jeffrey Tan[MSFT] - 12 Apr 2007 07:43 GMT
Hi Tomas,
Thanks for your feedback.
Yes, per your requirement, you may get it done by calling the static
Sleep() method of System::Threading::Thread class.
However, based on my my Winform programming experience, calling Sleep in
the GUI thread will prevent the message loop from doing it work, which
caused WM_PAINT, WM_SIZE and other messages not to be processed timely.
This will introduce an hang UI to the end user, which is considered to be
non user friendly.
If you care about this problem, then can you tell me why do you want to
delay/sleep 3 seconds between functions calling and before form closing?
Maybe you may put this function code in a second worker thread and let the
GUI thread responsible.
Anyway, if you think this is not a problem for your application, you may
just Sleep() method without any modification. Thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Tomas - 13 Apr 2007 10:44 GMT
I need close and open a file TXT that is used by another app.
If I do not put a delay between the processes I get an error message “files
is in use”.
Thanks for your help.

Signature
Tomas
Jeffrey Tan[MSFT] - 16 Apr 2007 03:46 GMT
Hi Tomas,
Thank your for the further context information on this issue.
Yes, I see you used the Sleep(3000) to delay the opening to the in use
file. However, this may be not be best design, because other processes may
lock the in use file for more than 3000ms. This will still make the opening
fail. So I still would recommend you to place the code in a second UI
thread, this will free the entire UI thread for painting. Also, you may use
try...catch to swallow the file in use exception.
Anyway, if you think your current design is applicable, you may still use
it without change. Thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Nathan Mates - 12 Apr 2007 17:28 GMT
>I need a stop between the functions and before to close de Form.
That's very unfriendly, and doesn't scale properly. You've
calculated how long a delay. What happens when someone runs your app
on a CPU twice as fast? Or half the speed? If you really do have code
that needs a fixed delay regardless of speed, why not just set a timer
(WM_TIMER in classic win32), and let the OS come back to you in a
while? That'll multitask better than a raw Sleep() call. If your
functions take a while, then use a thread and HEVENTs (win32 again,
not sure what the C# equivalent is) that signal when they're done?
Nathan Mates
--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein