I would like to call methods that are written in visual c++ 6.0 from the .NET environment.
If you know how to do this, please explain in the most simple way.
And if you can also send me a sample I will be glad and thankful!
If you have a com or com+ file, you can simply add a reference in VS.NET to that file (VS.NET will automatically create a RCW, a runtime callable wrapper for the file which is like a sort of proxy between the unmanaged code and the managed code) and use it in your .NET code.
i'm developing a client-server application and now i need to fix my asynchronously receive of messages because sometimes the complete message is not received on a single OnDataReceived call. I've tried for example to send a 18000 bytes long message with a 40000 bytes long receive buffer but there're 2 incoming packets of 13000 and 5000 bytes. My OnDataReceive function is this
public void OnDataReceived(IAsyncResult asyn)
// SocketPacket is a class with the buffer of packet
SocketPacket socketData = (SocketPacket)asyn.AsyncState ;
int iRx = 0 ;
// Complete the BeginReceive() asynchronous call by EndReceive() method
// which will return the number of characters written to the stream
// by the client
iRx = socketData.m_currentSocket.EndReceive (asyn);
if(iRx > 0)
// this get client object/class data (nickname, receive buffer for this client, socket)
ClientSocketType client = GetClientSocket(socketData.m_currentSocket);
if(client != null)
// create a new receiving buffer for this server/client receive
if(client.PacketBuffer == null)
client.PacketBuffer = new MemoryStream();
// append received buffers to that buffer
BinaryWriter binwrite = new BinaryWriter(client.PacketBuffer);
binwrite.Write(socketData.dataBuffer, 0, iRx);
// if packets for this message are finished process message
// ?!? WORKING ?
// prepare the stream and send to a parsing function
MemoryStream stream = new MemoryStream(client.PacketBuffer.GetBuffer(), 0, client.PacketBuffer.GetBuffer().Length,true, false);
ProcessMessage(socketData.m_currentSocket, stream );
Can anyone tell the diffrence btn. Multithreading and APPDOMAIN, as i know Appdomain is "Application domain is a construct in the CLR that is the unit of isolation for an application." and Mutithreading is " the ability of an operating system to concurrently run programs that have been divided into subcomponents, or threads"
So whats the diff. btn. two and which to be used when?
A thread typically runs a portion of code. If you have more than one thread running (by default they run at the same time) your application is multi-threading. For example, if you were calculating the value for pi to 100,000,000 digits it would take a very long time. You would still want a user to interact with your app while it's calculating, and not "freeze" your app. In this scenario you would use a thread to do the asynchronous work of calculating the value of pi.
An application domain is really just a box to run things in. When you create a new thread it, but default, runs in the application domain of your main program. Now, lets say you have 3 threads running and you haven't created any applicaiton domains. If one thread crashes they will all crash. An application domain gives you the security of keeping everything running inside it from influencing other processes. You can create single or nultiple threads in an application domain. So, if you have 3 threads and each one is in a different application domain, if one thread crashes the other two will continue to run.
That's the basics of it. I'd go to MSDN for the details about how app domains work in terms of security, isolation etc..
I have a DataGrid in my form that bound to a DataSet, I use background thread to update the data in the dataset, bacause there are a few threads working behind, I don;t want the updated data to be displayed in the Grid until all the threads finish. I try to use SuspendBinding, but it doesn't work.
Does anybody have idea of how to solve it?
MCAD for .NET Version
Great idea is the beginging of success!
You could, of course, create two DataSets, and with a simple assignment when your worker thread completes its operation, have the data inserted into the second data set. Then call the Data Binding method, binding to the second data set, and Refresh.
I'll bet you already thought of that, though,...
I used to use classwizard in VC++ 6.0, to add functionality of an event(eg: to override onLButtondown in view class).
I think, The classwizard is not available in VC++ 7.0(.Net version). So how to add this event.
Should I manually add the function signature in c++ and header file?