few lines translation from c# to VB.NET
-
Hi there, i found a really good article about multithread tcp handling, but i code in VB.NET and the source is in c#; i managed to translate most of the code, but some of them are out of my knowledge, please help ################## private Thread [] ThreadTask = new Thread[NUM_OF_THREAD] ; ThreadTask[i] = new Thread( new ThreadStart(this.Process) ); ThreadTask[i].Start() ; //NUM_OF_THREAD is a const ################## public ClientService(ClientConnectionPool ConnectionPool) { this .ConnectionPool = ConnectionPool ; } //is this a function ? a sub ? how do i translate 'this' ? ################## lock( ConnectionPool.SyncRoot ) { if ( ConnectionPool.Count > 0 ) client = ConnectionPool.Dequeue() ; } // lock opens {} as an if ? ################# Thanks in advance
-
Hi there, i found a really good article about multithread tcp handling, but i code in VB.NET and the source is in c#; i managed to translate most of the code, but some of them are out of my knowledge, please help ################## private Thread [] ThreadTask = new Thread[NUM_OF_THREAD] ; ThreadTask[i] = new Thread( new ThreadStart(this.Process) ); ThreadTask[i].Start() ; //NUM_OF_THREAD is a const ################## public ClientService(ClientConnectionPool ConnectionPool) { this .ConnectionPool = ConnectionPool ; } //is this a function ? a sub ? how do i translate 'this' ? ################## lock( ConnectionPool.SyncRoot ) { if ( ConnectionPool.Count > 0 ) client = ConnectionPool.Dequeue() ; } // lock opens {} as an if ? ################# Thanks in advance
the first bit declares an array of ThreadTasks containing NUM_OF_THREAD items, and then initialises and starts the ith member this in C# is Me in VB lock declares a critical section. I'm not sure what the VB equivalent is -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
-
Hi there, i found a really good article about multithread tcp handling, but i code in VB.NET and the source is in c#; i managed to translate most of the code, but some of them are out of my knowledge, please help ################## private Thread [] ThreadTask = new Thread[NUM_OF_THREAD] ; ThreadTask[i] = new Thread( new ThreadStart(this.Process) ); ThreadTask[i].Start() ; //NUM_OF_THREAD is a const ################## public ClientService(ClientConnectionPool ConnectionPool) { this .ConnectionPool = ConnectionPool ; } //is this a function ? a sub ? how do i translate 'this' ? ################## lock( ConnectionPool.SyncRoot ) { if ( ConnectionPool.Count > 0 ) client = ConnectionPool.Dequeue() ; } // lock opens {} as an if ? ################# Thanks in advance
Found it - lock in C# can be replaced by using the Monitor class in VB -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
-
Found it - lock in C# can be replaced by using the Monitor class in VB -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
-
the first bit declares an array of ThreadTasks containing NUM_OF_THREAD items, and then initialises and starts the ith member this in C# is Me in VB lock declares a critical section. I'm not sure what the VB equivalent is -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
Thanks,'me' worked perfectly I understood what private Thread [] ThreadTask = new Thread[NUM_OF_THREAD] say, the matter is that i cannot find a way to rewrite it in vb the only near declaration accepted from the syntax that i found is Private ThreadTask as Thread(NUM_OF_THREAD) but i miss the 'new' part. Any idea ? Thanks again for the kind help
-
Thanks,'me' worked perfectly I understood what private Thread [] ThreadTask = new Thread[NUM_OF_THREAD] say, the matter is that i cannot find a way to rewrite it in vb the only near declaration accepted from the syntax that i found is Private ThreadTask as Thread(NUM_OF_THREAD) but i miss the 'new' part. Any idea ? Thanks again for the kind help
Well, I'd just declare the array as you would any VB array, and try it like that. -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky