|
Looks like you want to use the ManualResetEvent/AutoResetEvent:
AutoResetEvent *m_wait = new AutoResetEvent( false );
if( m_wait->WaitOne( 1000, <exit-context-true-or-false> ) )
do-this-if-wait-was-signalled;
else
do-this-if-timed-out;
-------
For the above Wait to continue, either the time has to elapse or another thread has to execute the following code:
m_wait->Set();
Check out MSDN help.
|
|
|
|
|
thanks for your help !!!
|
|
|
|
|
Hi
Why are DataGrids in C++ .NET so slow?
I am creating a dataset, and a data table with a single row, and it takes a couple of seconds to display the initial data in a datagrid, what am i doing wrong?
cheers
|
|
|
|
|
I have also noticed this
on the first instantiation the system runs slow and for every other after the code runs much faster...
wish I could answer this one
|
|
|
|
|
Hi
Why are DataGrids in C++ .NET so slow?
I am creating a dataset, and a data table with a single row, and it takes a couple of seconds to display the initial data in a datagrid, what am i doing wrong?
cheers
|
|
|
|
|
I am from China, so please forgive my poor English.
I've got a terrible question when i try to use [FieldOffset ..] in C# to simulate the function of "union" in C.
this my code:
[StructLayout(LayoutKind.Explicit)]
public struct union
{
[FieldOffset(0)]
public union1 u1;
[FieldOffset(0)]
public union2 u2;
}
public struct union1
{
[MarshalAs (UnmanagedType.ByValArray,SizeConst=2)]
public byte[] arra1;
}
public struct union2
{
[MarshalAs(UnmanagedType.ByValArray,SizeConst=2)]
public byte[] arra2; //when I turn "byte" type to "int", it is OK! Or if i turn both "byte" to "int" in union1 and union2, it is OK too! ???
}
public void testUnion()
{
union u;
}
that is , I want to make a simple union comprising two "byte" Array at the
same offset, it's compiled successfully, but when i run testUnion(), i get a "System.TypeLoadException". What's more strange is that when i turn one or both of the two "byte" Array to "int" Array (or "long"), it just run Ok!
Any help will be deeply appreciated!
|
|
|
|
|
What is the best way to get x-number of bytes of memory into a byte array and back.
Basically I am trying to copy some unmanaged memory into and out of a DirectPlay NetworkPacket. I haven't found a clean (or semi-clean) solution yet.
Any ideas out there?
Thanks!
|
|
|
|
|
Have you tried System.Runtime.InteropServices.Marshal ?
void Copy(
IntPtr source,
unsigned char destination __gc[],
int startIndex,
int length
)
and
void Copy(
unsigned char source __gc[],
int startIndex,
IntPtr destination,
int length
)
|
|
|
|
|
Who can tell me the name of the Subscript 'operator[]' in ManagedC++?
For example the standard C++ assignment operator is 'operator=', but in managed C++ it is 'op_Assign'.
I tried 'op_Subscript', 'op_ArraySubscript' and some others. I need it to access arrays within a class directly (e.g. Classname[i] instead of Classname.Arrayname[i] (member) or Classname.Value(i) (function Value)) just to have a clear source code in complex matrix and vector computations.
Perhaps it is not implemented (yet) in C++ .NET (just like the standard class template). Microsoft did a very bad job here!
Thanks
Elwin
|
|
|
|
|
Hi,
I've created a managed C++ project, so the startup object is the 'Form1' object.
My problem is that I've created a second class called 'Form2' and I want to declare a variable of type 'Form1' within this class (Form2)... Howw can I do this ?
thanks.
|
|
|
|
|
You must add the #include "Form1.h" in stadfx.h and you should work in Form2.cpp where the stdafx.h is included by default.
In this way it works well!!
|
|
|
|
|
I have been looking all over without finding any proper explanation of how to use unmanaged C++ in C# with the help of managed C++. Can anyone please give a simple step by step guide how to create the projects and show what settings to fiddle around with? (Please don't give any links to MSDN, I allready checked them out and it didn't help (sure I might be stupid but not really that stupid..)).
Thank you.
|
|
|
|
|
go to the below url i have tried it and it works fine good luck.
http://www.codeproject.com/csharp/unmanage.asp
|
|
|
|
|
Thank you, but I'm still looking for a proper explanation of how to write wrapper classes in managed C++ for my unmanaged C++ classes. Sorry I didn't tell in the first message.
|
|
|
|
|
moist wrote:
how to write wrapper classes in managed C++ for my unmanaged C++ classes.
Look here[^]
|
|
|
|
|
I have allready seen the so called "Migration Guide" that consists of two parts, which the first one I find completly useless. I am able to write a wrapper class, but still I wonder how you can create three different projects in a solution, one for your unmanaged c++ class that you want to wrap, a second for your managed c++ wrapper class and third a c# project that uses the wrapper class. How to do that is not included in The Migration Guide.
|
|
|
|
|
You mean to tell me that all this is over knowing how to
add projects to a solution?
|
|
|
|
|
Yes.
Let's say that you have some nice C++ classes you implemented some while ago and that you want to use them in your C# project. I can't figure out how to create a new solution from scratch and then create three different projects; one unmanaged for your old C++ classes, a managed C++ project for your wrapper and a third for your C#. I guess the main problem I have is to choose the proper settings for the unmanaged project since there are no such thing as a unmanaged C++ class library. I beleived that this was a trvial task, but I still don't know how to get it working.
Thanks for the replies.
|
|
|
|
|
1. Wrap your unmanaged C/C++ code in a static library.
2. Make a Managed C++ DLL project, with all the Managed C++ wrapper classes. Link with the static library created in 1.
3. Use the DLL created in step 2, in a C# project of your choice.
It will work 100%.
|
|
|
|
|
Hi there,
I am wondering where i can learn Managed C++.NET. I had check out the msdn C++.NET specs. Very hard to learn.
I had no money to buy books.
And there are far too little tutorials on this area in google.
Only see some like Hello World, Sortting algorithm (mostly consoles).
I had no much knowledge in c++ so i can't be looking at application and learn it.
Any help please?
Thanks.
Regards,
Chua Wen Ching :p
|
|
|
|
|
|
Thanks.
I saw the articles are rated less than 4.. is it risky to read those?
Regards,
Chua Wen Ching :p
|
|
|
|
|
|
I actually disagree that this book is a worthy purchase. As I mentioned in a previous post, I personally know Richard and he is very good. However, this book is not up to his usually high standards.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - Jörgen Sigvardsson
|
|
|
|
|
When looking at the reviews on a Web public site such CodeProject, you have to realize that there are no prerequisites required for someone to post a rating. Therefore, while some of the reviews (both good and bad) are valid, there are many times when a person posting the rating might not be the best person to quantify the value of a given ariticle and in many cases, bad ratings can be directly attributed to personal issues between the rater and the article.
If you truly want to determine if an article is worth reading, I would first look at the remarks at the bottom of the article. Are there a lot of unanswered questions about bugs? Are a lot of errors being pointed out that are not being corrected in the article? In the case of Nish's articles, I think you'll find that the overwhelming majority of articles are top-notch and the few that had any problems were quickly corrected so that they're also top-notch now.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - Jörgen Sigvardsson
|
|
|
|