Beispiel #1
0
        /// <summary>
        /// Receive and execute new changes.
        /// </summary>
        /// <param name="sReader">Where new changes should be read.</param>
        /// <returns>True if changes have been read without problem, False otherwise.</returns>
        private bool receiveAndExecuteNewChanges(TextReader sReader)
        {
            while (true)
            {
                if (stopRequested)
                {
                    return(false);
                }

                string record = sReader.ReadLine();

                if (record == null || record[record.Length - 1] != '?')
                {
                    synch.CallbackError(Synchronization.ErrorType.ConnectionLost);
                    return(false);
                }

                if (record == "end;?")
                {
                    break;
                }

                Change    c;
                TimeEvent te;
                synch.ParseRecord(record, out c, out te);
                c.TimeEvent = te;
                synch.ExecuteChange(c, newTimeEvents, newChanges);
            }
            synch.WriteCaches(newTimeEvents, newChanges);
            return(true);
        }
        /// <summary>
        /// Execute new changes.
        /// </summary>
        /// <param name="client">Client's writer where potencial change should be send</param>
        /// <param name="sendChanges">Determine if it should be send new changes to client.</param>
        public void executeNewChanges(TextWriter client, bool sendChanges)
        {
            lock (resultChanges)
                synch.SynchronizeTotal = resultChanges.Count + 1;

            lock (resultChanges)
                foreach (var item in resultChanges)
                {
                    if (stopRequested)
                    {
                        client.WriteLine("end;?");
                        return;
                    }

                    synch.ExecuteNewChange(client, item.Key, item.Value, sendChanges, newChanges, newTimeEvents);
                    synch.Synchronized++;
                }
            synch.WriteCaches(newTimeEvents, newChanges);
            synch.Synchronized++;
            client.WriteLine("end;?");
        }