Пример #1
0
		public static void CompressionThread()
		{
			while( !Core.Closing )
			{
				m_Sync.WaitOne();

				int count;

				lock ( m_SendQueueSyncRoot )
					count = m_SendQueue.Count;

				while( count > 0 )
				{
					SendQueueEntry sqe = null;

					lock ( m_SendQueueSyncRoot )
						sqe = m_SendQueue.Dequeue();

					try
					{
						Packet p = null;

						lock( sqe.m_Root )
							p = sqe.m_Root.PacketCache;

						if( p == null )
						{
							p = new DesignStateDetailed( sqe.m_Serial, sqe.m_Revision, sqe.m_xMin, sqe.m_yMin, sqe.m_xMax, sqe.m_yMax, sqe.m_Tiles );
							p.SetStatic();

							lock( sqe.m_Root )
							{
								if( sqe.m_Revision == sqe.m_Root.Revision )
									sqe.m_Root.PacketCache = p;
							}
						}

						sqe.m_NetState.Send(p);
					}
					catch( Exception e )
					{
						Console.WriteLine( e );

						try
						{
							using( StreamWriter op = new StreamWriter( "dsd_exceptions.txt", true ) )
								op.WriteLine( e );
						}
						catch
						{
						}
					}
					finally
					{
						lock ( m_SendQueueSyncRoot )
							count = m_SendQueue.Count;
					}

					//sqe.m_NetState.Send( new DesignStateDetailed( sqe.m_Serial, sqe.m_Revision, sqe.m_xMin, sqe.m_yMin, sqe.m_xMax, sqe.m_yMax, sqe.m_Tiles ) );
				}
			}
		}
		public static void CompressionThread()
		{
			while( !Core.Closing )
			{
				m_Sync.WaitOne();

				while( m_SendQueue.Count > 0 )
				{
					SendQueueEntry sqe = (SendQueueEntry)m_SendQueue.Dequeue();

					try
					{
						Packet p = null;

						lock( sqe.m_Root )
							p = sqe.m_Root.PacketCache;

						if( p == null )
						{
							p = new DesignStateDetailed( sqe.m_Serial, sqe.m_Revision, sqe.m_xMin, sqe.m_yMin, sqe.m_xMax, sqe.m_yMax, sqe.m_Tiles );
							p.SetStatic();

							lock( sqe.m_Root )
							{
								if( sqe.m_Revision == sqe.m_Root.Revision )
									sqe.m_Root.PacketCache = p;
							}
						}

						Timer.DelayCall( TimeSpan.Zero, new TimerStateCallback( SendPacket_Sandbox ), new object[] { sqe.m_NetState, p } );
					}
					catch( Exception e )
					{
						Console.WriteLine( e );

						try
						{
							using( StreamWriter op = new StreamWriter( "dsd_exceptions.txt", true ) )
								op.WriteLine( e );
						}
						catch
						{
						}
					}

					//sqe.m_NetState.Send( new DesignStateDetailed( sqe.m_Serial, sqe.m_Revision, sqe.m_xMin, sqe.m_yMin, sqe.m_xMax, sqe.m_yMax, sqe.m_Tiles ) );
				}
			}
		}