|
Andrew Torrance wrote:
managed C++ my source code goes in the .h
Templated code? Templates belong in the .h
Andrew Torrance wrote:
my includes go in my .cpp
#include s belong in the .cpp, unless you *absolutly* need to have them in the .h, like you need for the includes of member variables.
Maybe its alright, or maybe your IDE needs ist weekend as well...
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Oops. Change the search start date and i found a question pertaining to this already. Seems to be a problem with vs.net 2002.
|
|
|
|
|
I'm trying to implement a collection class based on arraylist for a class library and I'm not sure how i'm supposed to get an indexer working with a covariant return type. I know covariance isn't spupporterd in mc++ but there's gotta be a way to create a custom collection......isn't there?
|
|
|
|
|
Hi,
Is there a 'WaitForSingleObject()' similar method in managed C++ ?
thanks.
|
|
|
|
|
|
The code below is my original unmanaged C++ code:
//**********************************************
UINT ThreadFunction(LPVOID pParam)
{
DWORD dwWait;
while (TRUE)
{
.
.
//do something
.
.
dwWait = WaitForSingleObject(m_event,1000);
if (dwWait == WAIT_OBJECT_0)
break;
}
return 0;
}
//**********************************************
I want to implement something like this.
Can you help me ?
Thanks in advance,
Camilo.
|
|
|
|
|
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%.
|
|
|
|