What is best place to close the stream socket listener? Is there any best practice to follow.
In general, we often make Dispose method for socket tool class, we could call StreamSocket.Dispose()
then call StreamSocketListener.Dispose()
at same time we need also to remove ConnectionReceived
event handler
public async override void Dispose()
{
clientSocket.Dispose();
Listener.ConnectionReceived -= OnConnection;
Listener?.CancelIOAsync();
Listener.Dispose();
Listener = null;
}