Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. few lines translation from c# to VB.NET

few lines translation from c# to VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharpquestionhelp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    notturno
    wrote on last edited by
    #1

    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

    I 2 Replies Last reply
    0
    • N notturno

      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

      I Offline
      I Offline
      Ian Darling
      wrote on last edited by
      #2

      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

      N 1 Reply Last reply
      0
      • N notturno

        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

        I Offline
        I Offline
        Ian Darling
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • I Ian Darling

          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

          N Offline
          N Offline
          notturno
          wrote on last edited by
          #4

          Thanks, i'll study it, i found just a few mins ago the synclock function, i hope it will work in a nice way but i'll check the monitor first

          1 Reply Last reply
          0
          • I Ian Darling

            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

            N Offline
            N Offline
            notturno
            wrote on last edited by
            #5

            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

            I 1 Reply Last reply
            0
            • N notturno

              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

              I Offline
              I Offline
              Ian Darling
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups