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. C#
  4. Parrallism in .NET

Parrallism in .NET

Scheduled Pinned Locked Moved C#
csharpdatabasesysadmin
2 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.
  • J Offline
    J Offline
    Joshua Nussbaum
    wrote on last edited by
    #1

    I came up with what I think :) is a good idea for making multithreading programming easier in any .NET language. .NET 2.0 adds the capability to write anonymous functions, it would be nice if there was a "parallel" statement, that could simplify writing threadprocs public void DoSomeParallelStuff() {  parallel  {   {     // do some network stuff     // this is an anonymous ThreadProc   }   {    // do some IO stuff   }   {    // do some DB stuff   }  }  // do other stuff, on caller thread } behind the scenes the compiler could create the anonymous functions, add them to the ThreadPool by calling ThreadPool.QueueUserWorkItem. in some cases it would be nice to automatically block the caller thread, maybe a sister statement "parallel-blocked" parrallel-blocked { { // read from drive c: StreamReader rd = new StreamReader("C:\test.txt"); ... } { // read from drive d: (done in parallel) StreamReader rd = new StreamReader("D:\test.txt"); ... } } // thread blocks until all parallel anonymous functions complete Console.WriteLine("Tasks complete"); I think this would make it much easier to write multithread capable code. I've actually added this feature to a compiler I'm working on and it works quite nicely. 60% of statistics are made up on the spot

    H 1 Reply Last reply
    0
    • J Joshua Nussbaum

      I came up with what I think :) is a good idea for making multithreading programming easier in any .NET language. .NET 2.0 adds the capability to write anonymous functions, it would be nice if there was a "parallel" statement, that could simplify writing threadprocs public void DoSomeParallelStuff() {  parallel  {   {     // do some network stuff     // this is an anonymous ThreadProc   }   {    // do some IO stuff   }   {    // do some DB stuff   }  }  // do other stuff, on caller thread } behind the scenes the compiler could create the anonymous functions, add them to the ThreadPool by calling ThreadPool.QueueUserWorkItem. in some cases it would be nice to automatically block the caller thread, maybe a sister statement "parallel-blocked" parrallel-blocked { { // read from drive c: StreamReader rd = new StreamReader("C:\test.txt"); ... } { // read from drive d: (done in parallel) StreamReader rd = new StreamReader("D:\test.txt"); ... } } // thread blocks until all parallel anonymous functions complete Console.WriteLine("Tasks complete"); I think this would make it much easier to write multithread capable code. I've actually added this feature to a compiler I'm working on and it works quite nicely. 60% of statistics are made up on the spot

      H Offline
      H Offline
      HopeDagger
      wrote on last edited by
      #2

      That would definitely be drool-worthy. Send a proposal to Microsoft and maybe it will see fruitation! :)

      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