Start() public method

Causes the operating system to change the state of the current thread instance to ThreadState.Running
public Start ( ) : void
return void
Ejemplo n.º 1
0
        /// <summary> Initially sets up server sockets and starts separate threads to accept connections
        /// on them.  Then loops, calling this.accept() super.newConnection().
        /// </summary>
        public override void Run()
        {
            try
            {
                AcceptThread             inAccept  = new AcceptThread(this, inboundPort, inSockets);
                AcceptThread             outAccept = new AcceptThread(this, outboundPort, outSockets);
                SupportClass.ThreadClass inThread  = new SupportClass.ThreadClass(new System.Threading.ThreadStart(inAccept.Run));
                SupportClass.ThreadClass outThread = new SupportClass.ThreadClass(new System.Threading.ThreadStart(outAccept.Run));
                inThread.Start();
                outThread.Start();

                while (keepRunning())
                {
                    NuGenConnection conn = accept(3000);
                    if (conn != null)
                    {
                        newConnection(conn);
                    }
                }

                inAccept.stop();
                outAccept.stop();
            }
            catch (System.Exception)
            {
            }
        }
Ejemplo n.º 2
0
 public virtual void  Init(IndexReader reader)
 {
     this.reader = reader;
     timeElapsed = 0;
     t           = new SupportClass.ThreadClass(new System.Threading.ThreadStart(this.Run));
     t.Start();
 }
Ejemplo n.º 3
0
        public static void  Main(System.String[] args)
        {
            if (args.Length != 2)
            {
                System.Console.Out.WriteLine("Usage: Genetibase.NuGenHL7.app.Initiator host port");
            }

            try
            {
                //set up connection to server
                System.String host = args[0];
                int           port = System.Int32.Parse(args[1]);

                Parser             parser     = new PipeParser();
                LowerLayerProtocol llp        = LowerLayerProtocol.makeLLP();
                NuGenConnection    connection = new NuGenConnection(parser, llp, new System.Net.Sockets.TcpClient(host, port));
                NuGenInitiator     initiator  = connection.Initiator;
                System.String      outText    = "MSH|^~\\&|||||||ACK^^ACK|||R|2.4|\rMSA|AA";

                //get a bunch of threads to send messages
                for (int i = 0; i < 1000; i++)
                {
                    SupportClass.ThreadClass sender = new SupportClass.ThreadClass(new System.Threading.ThreadStart(new AnonymousClassRunnable(parser, outText, initiator).Run));
                    sender.Start();
                }
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
Ejemplo n.º 4
0
 /// <summary> Starts the server listening for connections in a new thread.  This continues
 /// until <code>stop()</code> is called.
 /// </summary>
 public virtual void  start()
 {
     thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(this.Run));
     this.keepRunning_Renamed_Field = true;
     thd.Start();
     //Fix for bug 960101:  Don't start the cleaner thread until the server is started.
     SupportClass.ThreadClass cleaner = new SupportClass.ThreadClass(new System.Threading.ThreadStart(new NuGenHL7Service.ConnectionCleaner(this, this).Run));
     cleaner.Start();
 }
Ejemplo n.º 5
0
		/// <summary> Starts the server listening for connections in a new thread.  This continues 
		/// until <code>stop()</code> is called.  
		/// </summary>
		public virtual void  start()
		{
			thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(this.Run));
			this.keepRunning_Renamed_Field = true;
			thd.Start();            
			//Fix for bug 960101:  Don't start the cleaner thread until the server is started.
			SupportClass.ThreadClass cleaner = new SupportClass.ThreadClass(new System.Threading.ThreadStart(new NuGenHL7Service.ConnectionCleaner(this, this).Run));
			cleaner.Start();
		}
Ejemplo n.º 6
0
            /// <summary> Starts waiting in a separate thread for connections to the given
            /// ServerSocket from the given IP address.
            /// </summary>
            /// <param name="theServer">
            /// </param>
            /// <param name="theAddress">IP address from which to accept connections (null
            /// means any)
            /// </param>
            public Acceptor(System.Net.Sockets.TcpListener theServer, System.String theAddress)
            {
                Acceptor a = this;

                IThreadRunnable r = new AnonymousClassRunnable(a, theServer, theAddress, this);

                SupportClass.ThreadClass thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(r.Run));
                thd.Start();
            }
Ejemplo n.º 7
0
 public void  Listen()
 {
     listening = true;
     if (serverThread == null)
     {
         IThreadRunnable runnable = new FastServerThread(this);
         serverThread = new SupportClass.ThreadClass(new System.Threading.ThreadStart(runnable.Run), "FastServer");
     }
     serverThread.Start();
 }
Ejemplo n.º 8
0
        /// <summary> Starts accepting connections in a new Thread.  Note that this can be
        /// called multiple times with separate addresses.  The stop() method ends
        /// all Threads started here.
        ///
        /// </summary>
        /// <param name="theAddress">IP address from which connections are accepted (null
        /// means any address is OK)
        /// </param>
        public virtual void  start(System.String theAddress)
        {
            NuGenHL7Server  server   = this;
            IThreadRunnable acceptor = new AnonymousClassRunnable(server, theAddress, this);

            myIsRunning = true;

            SupportClass.ThreadClass thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(acceptor.Run));
            thd.Start();
        }
Ejemplo n.º 9
0
        /// <summary> Decompresses audio data from an InputStream and plays it
        /// back through an AudioDevice. The playback is run on a newly
        /// created thread.
        ///
        /// </summary>
        /// <param name="in	The">InputStream that provides the MPEG audio data.
        /// </param>
        /// <param name="dev	The">AudioDevice to use to sound the decompressed data.
        ///
        /// @throws JavaLayerException if there was a problem decoding
        /// or playing the audio data.
        ///
        /// </param>
        protected internal virtual void  play(System.IO.Stream @in, AudioDevice dev)
        {
            stopPlayer();

            if (@in != null && dev != null)
            {
                player       = new Player(@in, dev);
                playerThread = createPlayerThread();
                playerThread.Start();
            }
        }
Ejemplo n.º 10
0
        /// <summary> Sets up the FilterManager singleton.</summary>
        protected internal FilterManager()
        {
            cache          = new System.Collections.Hashtable();
            cacheCleanSize = DEFAULT_CACHE_CLEAN_SIZE;             // Let the cache get to 100 items
            cleanSleepTime = DEFAULT_CACHE_SLEEP_TIME;             // 10 minutes between cleanings

            filterCleaner = new FilterCleaner(this);
            SupportClass.ThreadClass fcThread = new SupportClass.ThreadClass(new System.Threading.ThreadStart(filterCleaner.Run));
            // setto be a Daemon so it doesn't have to be stopped
            fcThread.IsBackground = true;
            fcThread.Start();
        }
Ejemplo n.º 11
0
 private void  ListenForMessages()
 {
     if (listeningThread == null)
     {
         IThreadRunnable messageReader = new SessionThread(this);
         listeningThread = new SupportClass.ThreadClass(new System.Threading.ThreadStart(messageReader.Run), "FAST Session Message Reader");
     }
     if (listeningThread.IsAlive)
     {
         return;
     }
     listeningThread.Start();
 }
Ejemplo n.º 12
0
        /// <summary>Sends in a new thread if isThreaded, otherwise in current thread </summary>
        private void  sendAppResponse(NuGenTransportable theResponse)
        {
            NuGenProcessorImpl processor = this;
            IThreadRunnable    sender    = new AnonymousClassRunnable(processor, theResponse, this);

            if (myThreaded)
            {
                SupportClass.ThreadClass thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(sender.Run));
                thd.Start();
            }
            else
            {
                sender.Run();
            }
        }
Ejemplo n.º 13
0
        /// <param name="theContext">source of supporting services
        /// </param>
        /// <param name="isThreaded">true if this class should create threads in which to call cycle(), and
        /// in which to send responses from Applications.  This is the preferred mode.  Use false
        /// if threading is not allowed, eg you are running the code in an EJB container.  In this case,
        /// the send() and receive() methods will call cycle() themselves as needed.  However, cycle()
        /// makes potentially blocking calls, so these methods may not return until the next message
        /// is received from the remote server, regardless of timeout.  Probably the worst example of this
        /// would be if receive() was called to wait for an application ACK that was specified as "RE" (ie
        /// required on error).  No response will be returned if the message is processed without error,
        /// and in a non-threaded environment, receive() will block forever.  Use true if you can, otherwise
        /// study this class carefully.
        ///
        /// TODO: write a MLLPTransport with non-blocking IO
        /// TODO: reconnect transport layers on error and retry
        /// </param>
        public NuGenProcessorImpl(NuGenProcessorContext theContext, bool isThreaded)
        {
            myContext           = theContext;
            myThreaded          = isThreaded;
            myAcceptAcks        = new System.Collections.Hashtable();
            myReservations      = new System.Collections.Hashtable();
            myAvailableMessages = new System.Collections.Hashtable();

            if (isThreaded)
            {
                ackCycler = new Cycler(this, true);
                SupportClass.ThreadClass ackThd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(ackCycler.Run));
                ackThd.Start();
                nonAckCycler = new Cycler(this, false);
                SupportClass.ThreadClass nonAckThd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(nonAckCycler.Run));
                nonAckThd.Start();
            }
        }
Ejemplo n.º 14
0
 /// <summary>Starts the Receiver in a new thread </summary>
 public virtual void  start()
 {
     running = true;
     SupportClass.ThreadClass thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(this.Run));
     thd.Start();
 }
Ejemplo n.º 15
0
        internal void sendMessage()
        {
            conn.writeMessage(this);
            // Start the timer thread
            if (mslimit != 0)
            {
                // Don't start the timer thread for abandon or Unbind
                switch (msg.Type)
                {

                    case LdapMessage.ABANDON_REQUEST:
                    case LdapMessage.UNBIND_REQUEST:
                        mslimit = 0;
                        break;

                    default:
                        timer = new Timeout(this, mslimit, this);
                        timer.IsBackground = true; // If this is the last thread running, allow exit.
                        timer.Start();
                        break;

                }
            }
            return ;
        }
Ejemplo n.º 16
0
        /// <summary> Decompresses audio data from an InputStream and plays it
        /// back through an AudioDevice. The playback is run on a newly
        /// created thread. 
        /// 
        /// </summary>
        /// <param name="in	The">InputStream that provides the MPEG audio data.
        /// </param>
        /// <param name="dev	The">AudioDevice to use to sound the decompressed data. 
        /// 
        /// @throws JavaLayerException if there was a problem decoding
        /// or playing the audio data.
        /// 
        /// </param>
        protected internal virtual void play(System.IO.Stream @in, AudioDevice dev)
        {
            stopPlayer();

            if (@in != null && dev != null)
            {
                player = new Player(@in, dev);
                playerThread = createPlayerThread();
                playerThread.Start();
            }
        }
Ejemplo n.º 17
0
		/// <summary>Starts the Receiver in a new thread </summary>
		public virtual void  start()
		{
			running = true;
			SupportClass.ThreadClass thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(this.Run));
			thd.Start();
		}
Ejemplo n.º 18
0
		/// <summary>startReader
		/// startReader should be called when socket and io streams have been
		/// set or changed.  In particular after client.Connection.startTLS()
		/// It assumes the reader thread is not running.
		/// </summary>
		/* package */
		internal void  startReader()
		{
			// Start Reader Thread
			SupportClass.ThreadClass r =new SupportClass.ThreadClass(new System.Threading.ThreadStart(new ReaderThread(this).Run));
//			Thread r = new Thread(new ThreadStart(new ReaderThread(this).Run));
			r.IsBackground = true; // If the last thread running, allow exit.
			r.Start();
			waitForReader(r);
			return ;
		}
Ejemplo n.º 19
0
		public virtual void  Init(IndexReader reader)
		{
			this.reader = reader;
			timeElapsed = 0;
			t = new SupportClass.ThreadClass(new System.Threading.ThreadStart(this.Run));
			t.Start();
		}
Ejemplo n.º 20
0
		public static void  Main(System.String[] args)
		{
			if (args.Length != 2)
			{
				System.Console.Out.WriteLine("Usage: Genetibase.NuGenHL7.app.Initiator host port");
			}
			
			try
			{
				
				//set up connection to server
				System.String host = args[0];
				int port = System.Int32.Parse(args[1]);
				
				Parser parser = new PipeParser();
				LowerLayerProtocol llp = LowerLayerProtocol.makeLLP();
				NuGenConnection connection = new NuGenConnection(parser, llp, new System.Net.Sockets.TcpClient(host, port));
				NuGenInitiator initiator = connection.Initiator;
				System.String outText = "MSH|^~\\&|||||||ACK^^ACK|||R|2.4|\rMSA|AA";
				
				//get a bunch of threads to send messages
				for (int i = 0; i < 1000; i++)
				{
					SupportClass.ThreadClass sender = new SupportClass.ThreadClass(new System.Threading.ThreadStart(new AnonymousClassRunnable(parser, outText, initiator).Run));
					sender.Start();
				}
			}
			catch (System.Exception e)
			{
				SupportClass.WriteStackTrace(e, Console.Error);
			}
		}
			/// <summary> Starts waiting in a separate thread for connections to the given 
			/// ServerSocket from the given IP address.  
			/// </summary>
			/// <param name="theServer">
			/// </param>
			/// <param name="theAddress">IP address from which to accept connections (null
			/// means any) 
			/// </param>
			public Acceptor(System.Net.Sockets.TcpListener theServer, System.String theAddress)
			{
				Acceptor a = this;
				
				IThreadRunnable r = new AnonymousClassRunnable(a, theServer, theAddress, this);
				
				SupportClass.ThreadClass thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(r.Run));
				thd.Start();
			}
Ejemplo n.º 22
0
 /// <summary> Initializes and starts the ChannelListener that waits for results or
 /// errors from the Jamocha engine.
 /// 
 /// </summary>
 private void initChannelListener()
 {
     channelListener = new AnonymousClassThread(this);
     channelListener.Start();
 }
Ejemplo n.º 23
0
		/// <summary> Starts accepting connections in a new Thread.  Note that this can be 
		/// called multiple times with separate addresses.  The stop() method ends
		/// all Threads started here.  
		/// 
		/// </summary>
		/// <param name="theAddress">IP address from which connections are accepted (null 
		/// means any address is OK) 
		/// </param>
		public virtual void  start(System.String theAddress)
		{
			NuGenHL7Server server = this;
			IThreadRunnable acceptor = new AnonymousClassRunnable(server, theAddress, this);
			
			myIsRunning = true;
			
			SupportClass.ThreadClass thd = new SupportClass.ThreadClass(new System.Threading.ThreadStart(acceptor.Run));
			thd.Start();
		}
Ejemplo n.º 24
0
 private void Start()
 {
     go = new object();
     async = new object();
     thread = new SupportClass.ThreadClass(new System.Threading.ThreadStart(this.Run));
     thread.Start();
 }