private CancellationTokenSource CreateNewManagedCancellationTokenSource()
        {
            //Cretae and add to the token sources.
            CancellationTokenSource source = new CancellationTokenSource();

            TaskTokenSources.Add(source);
            return(source);
        }
        //TODO: Is it safe to make this method public? We made it public for the server stuff
        /// <summary>
        /// Stops the network tasks for the client.
        /// </summary>
        public void StopNetwork()
        {
            //Before disconnecting the managed client we should cancel all the tokens used for
            //running the tasks
            TaskTokenSources.ForEach(t =>
            {
                t.Cancel();

                //TODO: Is it safe not to dipose?
            });

            TaskTokenSources.Clear();
        }