i want to be able to use reactive to receive udp packages asynchronously. i've written this block of code.
udpServer = new UdpClient(20000);
remoteEP = new IPEndPoint(IPAddress.Any, 20000);
var read = Observable.FromAsyncPattern(udpServer.BeginReceive, t => udpServer.EndReceive(t, ref remoteEP));
then i consume this function and store the IObservable resulting.
reader = read()
.Do(s =>
{
Logs.Add(System.Text.Encoding.UTF8.GetString(s));
})
.DoOnError(ex => status = ex.Message; );
when i subscribe finally, the operation happens only once then observer gets disposed with on complete.
and here comes my question : is there a way to make this code work continuously ? to receive the "DO" operation every time new logs are received?
sidebar: just wonder whats the point with Observable.FromAsyncPattern if i can't reuse it, im better off statically typing 2 methods for the begin and end instead of getting the overhead of more instances of classes that needs disposal later.
-im also open for whole other different options except using TPL.