home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Language specific support
Deutsches MediaPortal Forum
Hard- und Software rund um den HTPC
Hardware
TV-Karten
Digital Devices Octopus NET CT/2 Erfahrungen?
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="mnmr" data-source="post: 1060262" data-attributes="member: 86308"><p>Ah, OK. I was under the impression that this was a dependency for MP.</p><p></p><p>[CODE] var thd = new Thread(() => GetSocketResponse(socket));</p><p> socket.SendTo(broadcastMessage, 0, broadcastMessage.Length, SocketFlags.None, new IPEndPoint(multicastAddress, multicastPort));</p><p> thd.Start();</p><p> Thread.Sleep(searchTimeOut);[/CODE]</p><p></p><p>I know this is sample code, so you probably know all this.. anyway, a few things I noticed:</p><p>- you're creating a Thread that is never terminated; also, why create a thread to process the result, if the original thread is doing nothing but sleeping <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /> If you do want to execute a background task, consider using ThreadPool.QueueUserWorkItem (fire and forget) or Task.Run.</p><p>- you're creating a WebClient that is never released</p><p></p><p>The solution is probably to call the GetSocketResponse in a loop from the GetSsdpListener method and to use a CancellationToken with a timeout to ensure the loop exits (the timeout probably also needs to be set on the Socket to ensure the method exits), which gives you a place to clean up resources as well.</p><p></p><p>Is this all the library does? This is more like a utility method than a library <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="mnmr, post: 1060262, member: 86308"] Ah, OK. I was under the impression that this was a dependency for MP. [CODE] var thd = new Thread(() => GetSocketResponse(socket)); socket.SendTo(broadcastMessage, 0, broadcastMessage.Length, SocketFlags.None, new IPEndPoint(multicastAddress, multicastPort)); thd.Start(); Thread.Sleep(searchTimeOut);[/CODE] I know this is sample code, so you probably know all this.. anyway, a few things I noticed: - you're creating a Thread that is never terminated; also, why create a thread to process the result, if the original thread is doing nothing but sleeping :) If you do want to execute a background task, consider using ThreadPool.QueueUserWorkItem (fire and forget) or Task.Run. - you're creating a WebClient that is never released The solution is probably to call the GetSocketResponse in a loop from the GetSsdpListener method and to use a CancellationToken with a timeout to ensure the loop exits (the timeout probably also needs to be set on the Socket to ensure the method exits), which gives you a place to clean up resources as well. Is this all the library does? This is more like a utility method than a library :) [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Language specific support
Deutsches MediaPortal Forum
Hard- und Software rund um den HTPC
Hardware
TV-Karten
Digital Devices Octopus NET CT/2 Erfahrungen?
Contact us
RSS
Top
Bottom