public void Run() { ThreadPool.QueueUserWorkItem((o) => { try { while (listener.IsListening) { ThreadPool.QueueUserWorkItem((c) => { HttpListenerContext context = c as HttpListenerContext; try { byte[] data = new byte[1024]; context.Request.InputStream.Read(data, 0, data.Length); string rawString = Encoding.UTF8.GetString(data).Replace("\0", String.Empty); SongData song = SongData.Parse(rawString); song.FetchLyrics(); Dispatcher.Invoke(() => loadFromSongToGUI(song)); notifyAndroidDevice(song); byte[] buf = Encoding.UTF8.GetBytes("penis"); context.Response.ContentLength64 = buf.Length; context.Response.OutputStream.Write(buf, 0, buf.Length); } catch (Exception e) { } finally { context.Response.OutputStream.Close(); } }, listener.GetContext()); } } catch (Exception e) { } }); }