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. The Lounge
  3. That's Cool

That's Cool

Scheduled Pinned Locked Moved The Lounge
mobiledesignsysadminannouncement
21 Posts 8 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.
  • L Lost User

    Nice, which solution did you use?

    R Offline
    R Offline
    realJSOP
    wrote on last edited by
    #10

    I used the one I cited (no offense to Grif, of course).

    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
    -----
    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
    -----
    "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

    L 1 Reply Last reply
    0
    • R realJSOP

      I used the one I cited (no offense to Grif, of course).

      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
      -----
      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
      -----
      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #11

      I could be missing something here, but the link went to the question, not to an answer

      R 1 Reply Last reply
      0
      • R realJSOP

        In my media at home project, I discovered the need to scan the local network for connected machines. My idea was to start with the local machine's IP in order to establish the applicable subnet, and then cycle through each IP address in that subnet, and see if a device is assigned to that IP. If the IP isn't found, it takes about 10 seconds to timeout (and throw an exception). Without multi-threading, it takes over 38 minutes to scan (from x.x.x.1 to x.x.x.255), and because it's performed on the UI thread, the app remains completely unresponsive while it's running. WITH multi-threading - it takes 1 minute, and the main window remains completely responsive. When I target just the ranges of IP's I know are in use (+/- 5 IPs on either side of each range), the threaded version takes just 12 seconds.

        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
        -----
        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
        -----
        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

        T Offline
        T Offline
        TheCardinal
        wrote on last edited by
        #12

        and when are you releasing this cool stuff? been waiting an update on this project :-)

        Life - Dreams = Job TheCardinal

        1 Reply Last reply
        0
        • R realJSOP

          In my media at home project, I discovered the need to scan the local network for connected machines. My idea was to start with the local machine's IP in order to establish the applicable subnet, and then cycle through each IP address in that subnet, and see if a device is assigned to that IP. If the IP isn't found, it takes about 10 seconds to timeout (and throw an exception). Without multi-threading, it takes over 38 minutes to scan (from x.x.x.1 to x.x.x.255), and because it's performed on the UI thread, the app remains completely unresponsive while it's running. WITH multi-threading - it takes 1 minute, and the main window remains completely responsive. When I target just the ranges of IP's I know are in use (+/- 5 IPs on either side of each range), the threaded version takes just 12 seconds.

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #13

          Hmmm... I just completed a data gathering service that goes out to all the servers in my SCCM infrastructure and gathers a bunch of data on each. It's all Task based and takes 2 to 3 seconds to get the server inventory from SCCM then scan the (currently) 26 servers I have. I know it's not scanning a range of IP's, but 12 seconds seems long to have 1 Task per IP to hit 253 IP's.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          R 1 Reply Last reply
          0
          • L Lost User

            I could be missing something here, but the link went to the question, not to an answer

            R Offline
            R Offline
            realJSOP
            wrote on last edited by
            #14

            Oops - look at the last answer.

            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
            -----
            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              Hmmm... I just completed a data gathering service that goes out to all the servers in my SCCM infrastructure and gathers a bunch of data on each. It's all Task based and takes 2 to 3 seconds to get the server inventory from SCCM then scan the (currently) 26 servers I have. I know it's not scanning a range of IP's, but 12 seconds seems long to have 1 Task per IP to hit 253 IP's.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak

              R Offline
              R Offline
              realJSOP
              wrote on last edited by
              #15

              It's also enumerating shared disks when it finds an active IP.

              ".45 ACP - because shooting twice is just silly" - JSOP, 2010
              -----
              You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
              -----
              "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

              1 Reply Last reply
              0
              • R realJSOP

                I found another way here: http://stackoverflow.com/questions/997046/gethostentry-is-very-slow[^] It took the non-threaded version down to two minutes, and the threaded one down to 1 second. (Checking all IPs from 1 to 255).

                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                -----
                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                -----
                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                S Offline
                S Offline
                SoMad
                wrote on last edited by
                #16

                This is great information. I don't need it right now, but I have bookmarked it. Soren Madsen

                1 Reply Last reply
                0
                • R realJSOP

                  In my media at home project, I discovered the need to scan the local network for connected machines. My idea was to start with the local machine's IP in order to establish the applicable subnet, and then cycle through each IP address in that subnet, and see if a device is assigned to that IP. If the IP isn't found, it takes about 10 seconds to timeout (and throw an exception). Without multi-threading, it takes over 38 minutes to scan (from x.x.x.1 to x.x.x.255), and because it's performed on the UI thread, the app remains completely unresponsive while it's running. WITH multi-threading - it takes 1 minute, and the main window remains completely responsive. When I target just the ranges of IP's I know are in use (+/- 5 IPs on either side of each range), the threaded version takes just 12 seconds.

                  ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                  -----
                  You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                  -----
                  "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #17

                  You have 256 tasks, which at least originally took several seconds, but reliably end, no matter if successful or not. They can be carried out independently without any data synchronization, you just have to go through the results afterwards. That screams for parallel processing. The conditions could not be better. I can't believe that this is a real surprise to an old trapper like you. Just out of curiosity: Did you really use 256 instances of a custom thread class or simply use the Parallel class, something like a Parallel.For() loop?

                  R 2 Replies Last reply
                  0
                  • L Lost User

                    You have 256 tasks, which at least originally took several seconds, but reliably end, no matter if successful or not. They can be carried out independently without any data synchronization, you just have to go through the results afterwards. That screams for parallel processing. The conditions could not be better. I can't believe that this is a real surprise to an old trapper like you. Just out of curiosity: Did you really use 256 instances of a custom thread class or simply use the Parallel class, something like a Parallel.For() loop?

                    R Offline
                    R Offline
                    realJSOP
                    wrote on last edited by
                    #18

                    It's not a surprise, and I'm using the Task thingamajig...

                    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                    -----
                    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                    -----
                    "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                    1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      Cool - but there is a simpler way: Retrieving IP and MAC addresses for a LAN[^]

                      If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

                      C Offline
                      C Offline
                      cptKoala
                      wrote on last edited by
                      #19

                      tss... shameless self-promotion (but bookmarked and fived anyway) ;)

                      OriginalGriffO 1 Reply Last reply
                      0
                      • C cptKoala

                        tss... shameless self-promotion (but bookmarked and fived anyway) ;)

                        OriginalGriffO Offline
                        OriginalGriffO Offline
                        OriginalGriff
                        wrote on last edited by
                        #20

                        Well I'm not typing it out again! :laugh:

                        If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                        1 Reply Last reply
                        0
                        • L Lost User

                          You have 256 tasks, which at least originally took several seconds, but reliably end, no matter if successful or not. They can be carried out independently without any data synchronization, you just have to go through the results afterwards. That screams for parallel processing. The conditions could not be better. I can't believe that this is a real surprise to an old trapper like you. Just out of curiosity: Did you really use 256 instances of a custom thread class or simply use the Parallel class, something like a Parallel.For() loop?

                          R Offline
                          R Offline
                          realJSOP
                          wrote on last edited by
                          #21

                          I did it this way:

                          //--------------------------------------------------------------------------------
                          public static void GetLanMachinesThreaded(System.Windows.Threading.Dispatcher dispatcher,
                          List<HostAddress> subnet,
                          Control control,
                          bool setItemsSource=false)
                          {
                          List<Task> tasks = new List<Task>();
                          foreach(HostAddress item in subnet)
                          {
                          var t = Task.Factory.StartNew(() => { item.FindHost(); });
                          tasks.Add(t);
                          }
                          Task.Factory.ContinueWhenAll(tasks.ToArray(), result =>
                          {
                          subnet.RemoveAll(item => item.Host == null || item.Shares.Count == 0);
                          if (control != null)
                          {
                          if (control is ItemsControl && setItemsSource)
                          {
                          dispatcher.BeginInvoke(new Action(() => ((ItemsControl)control).ItemsSource = subnet));
                          }
                          dispatcher.BeginInvoke(new Action(() => control.Focus()));
                          }
                          });
                          }

                          The item.FindHost method searches for the IP's specified in the subnet parameter, and then looks for disk shares on hosts that were found. once that's completed, it removes shares that are specified in a filter list (default shares, and anything that isn't a disk share), and then removes any hosts that end up with no shares found. If the disks are spun up from recent access, it now takes about 25 seconds (because of the disk share enumeration). If the disks aren't spun up, it takes almost twice as long. Since this only happens when the user specifically wants to add a new shared media source, I think the performance is acceptable, and I'm not sure it could be made much (if any) faster.

                          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                          -----
                          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                          -----
                          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                          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