Results 1 to 2 of 2

Thread: CancellationTokenSource in GetHostEntryAsync (and ping)

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    CancellationTokenSource in GetHostEntryAsync (and ping)

    Hi.
    I'm using this example for multiple net calls: https://docs.microsoft.com/en-us/dot...-they-complete
    However I'm changing it a little as I need to get the computers on multiple networks and IP's so I'm using GetHostEntryAsync .
    I'm reading that there is no cancellation token on this one, correct? So I just leave it to run orrrr..what? The app get 0 to 255 addresses on a loop an is doing about 1 minute but I'm not sure if I'm blocking our network doing so (can't check right now as we are on a lockdown and I have all the net resources available to "experiment" ) . So is there a way I cancel the retrieval, or I need to close the app (also closing the app cancel or do I need to force an app.exit or something similar?) ?

    Second question. Is there anything else than a ping to get computers that are currently online . I'm asking this because I get most of the computers with GetHostEntryAsync but they are probable cached on the DNS because they are not online but I get the IP and name in most of them. I guess a ping will get the status but I was looking for something faster as ping as it has that specific "pause" when calling it ( at least on a command prompt, not sure yet if there is a delay setting I can use on .net) . Also is there an async ping with cancellation?

    Thanks.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  2. #2

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: CancellationTokenSource in GetHostEntryAsync (and ping)

    OK. There is a System.Net.NetworkInformation ping that uses async and has a cancellation token.
    So I'll try this but it think it will do.
    So for now only the initial question stands.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width