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)<br/>
// SocketPacket is a class with the buffer of packet<br/>
SocketPacket socketData = (SocketPacket)asyn.AsyncState ;<br/><br/>
int iRx = 0 ;<br/>
// Complete the BeginReceive() asynchronous call by EndReceive() method<br/>
// which will return the number of characters written to the stream <br/>
// by the client<br/>
iRx = socketData.m_currentSocket.EndReceive (asyn);<br/>
if(iRx > 0)<br/>
// this get client object/class data (nickname, receive buffer for this client, socket)<br/>
ClientSocketType client = GetClientSocket(socketData.m_currentSocket);<br/><br/>
if(client != null)<br/>
// create a new receiving buffer for this server/client receive<br/>
if(client.PacketBuffer == null)<br/>
client.PacketBuffer = new MemoryStream();<br/><br/>
// append received buffers to that buffer<br/>
BinaryWriter binwrite = new BinaryWriter(client.PacketBuffer);<br/>
binwrite.Write(socketData.dataBuffer, 0, iRx);<br/><br/>
// if packets for this message are finished process message<br/>
// ?!? WORKING ?<br/>
// prepare the stream and send to a parsing function<br/>
MemoryStream stream = new MemoryStream(client.PacketBuffer.GetBuffer(), 0, client.PacketBuffer.GetBuffer().Length,true, false);<br/>
ProcessMessage(socketData.m_currentSocket, stream );<br/><br/>
// empty client receive buffer<br/>
client.PacketBuffer = null;<br/>
// Continue the waiting for data on the Socket<br/>
WaitForData( socketData.m_currentSocket );<br/>
AddLogMessage("Disconnected user"); <br/>
catch (ArgumentNullException se)<br/>
AddLogMessage(se.Message ); <br/>
catch (ObjectDisposedException )<br/>
System.Diagnostics.Debugger.Log(0,"1","\nOnDataReceived: Socket has been closed\n");<br/>
if(se.ErrorCode == 10054)<br/>
AddLogMessage("User disconnected: no ping received");<br/>
asyn.IsCompleted gives always True and i'm not able to understand how the message is fully received. What i need to change in this logic?
First of all, if you compile your project in VS 2003, it will use the .NET 1.1 runtime. You can also make it support the 1.0 runtime through your project properties in VS.NET.
"Modifying this property causes the project system to update the web.config file in your project by adding assembly binding (<bindingredirect> and <assemblyidentity>) tags in a <dependentassembly> section. Web pages in Visual Studio-built ASP.NET Web applications are precompiled to a .dll file with a dependency on the runtime associated with the compiler."
I guess setting that option in the ASP.NET tab, will compile the aspx pages on runtime to one supporting the 2.0 runtime (but not the pre compiled files, since that option was set in VS.NET)
So if you would compile your project in VS.NET 2005, it will use the .NET 2.0 runtime.
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,...
Actually, in my experience whery big ammount of inserts is allways not too fast, especially if you are executing it in some kind of for() or while() cycle.
Some time ago I created a 2D map in database where insert was wery simple like that: insert (x,y, <somemaptype>) values (1,2,34). In my case I used 2 for() cycles and OdbcConnection with OdbcCommand. insert statement was executed 1`000`000 times and it took 15-20 minutes because someMapType was Random generated number.
I suggest you have to check and try optimize your code, maybe even create transaction sql file and execute it in database side with you oledb. And there is one more thing - Access is the sickest database I ever seen. Maybe you should try some other database.
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?