Inheritance: System.IO.IOException
Ejemplo n.º 1
0
        public virtual void Run()
        {
            Thread runThread = Thread.CurrentThread();

            if (runThread.IsCanceled)
            {
                return;
            }

            Exception ex0 = null;

            try
            {
                DoConnect();
            }
            catch (Exception ex)
            {
                ex0 = ex;
                // Defer to below where we're locked
                return;
            }
            finally
            {
                lock (runThread)
                {
                    if (!runThread.IsCanceled)
                    {
                        if (!runThread.Equals(Thread))
                        {
                            if (ex0 != null)
                            {
                                if (Log.Level >= 2)
                                {
                                    Runtime.PrintStackTrace(ex0, Log);
                                }
                            }
                            //return;
                        }
                        if (ex0 != null)
                        {
                            Te = new TransportException(ex0);
                        }
                        State = 2;
                        // run connected
                        Runtime.Notify(runThread);
                    }
                }
            }

            if (runThread.IsCanceled)
            {
                return;
            }

            Loop();
        }
Ejemplo n.º 2
0
        /// <exception cref="SharpCifs.Util.Transport.TransportException"></exception>
        public virtual void Connect(long timeout)
        {
            lock (this)
            {
                try
                {
                    switch (State)
                    {
                    case 0:
                    {
                        break;
                    }

                    case 3:
                    {
                        return;
                    }

                    case 4:
                    {
                        // already connected
                        State = 0;
                        throw new TransportException("Connection in error", Te);
                    }

                    default:
                    {
                        //TransportException te = new TransportException("Invalid state: " + state);
                        State = 0;
                        throw new TransportException("Invalid state: " + State);
                    }
                    }
                    State  = 1;
                    Te     = null;
                    Thread = new Thread(this);
                    Thread.SetDaemon(true);
                    lock (Thread)
                    {
                        Thread.Start();
                        Runtime.Wait(Thread, timeout);
                        switch (State)
                        {
                        case 1:
                        {
                            State  = 0;
                            Thread = null;
                            throw new TransportException("Connection timeout");
                        }

                        case 2:
                        {
                            if (Te != null)
                            {
                                State  = 4;
                                Thread = null;
                                throw Te;
                            }
                            State = 3;
                            return;
                        }
                        }
                    }
                }
                catch (Exception ie)
                {
                    State  = 0;
                    Thread = null;
                    throw new TransportException(ie);
                }
                finally
                {
                    if (State != 0 && State != 3 && State != 4)
                    {
                        if (Log.Level >= 1)
                        {
                            Log.WriteLine("Invalid state: " + State);
                        }
                        State  = 0;
                        Thread = null;
                    }
                }
            }
        }
Ejemplo n.º 3
0
		public virtual void Run()
		{
			Thread runThread = Thread.CurrentThread();
			Exception ex0 = null;
			try
			{
				DoConnect();
			}
			catch (Exception ex)
			{
				ex0 = ex;
				// Defer to below where we're locked
				return;
			}
			finally
			{
				lock (runThread)
				{
					if (runThread != Thread)
					{
						if (ex0 != null)
						{
							if (Log.Level >= 2)
							{
								Runtime.PrintStackTrace(ex0, Log);
							}
						}
						//return;
					}
					if (ex0 != null)
					{
						Te = new TransportException(ex0);
					}
					State = 2;
					// run connected
					Runtime.Notify(runThread);
				}
			}
			Loop();
		}
Ejemplo n.º 4
0
		/// <exception cref="SharpCifs.Util.Transport.TransportException"></exception>
		public virtual void Connect(long timeout)
		{
			lock (this)
			{
				try
				{
					switch (State)
					{
						case 0:
						{
							break;
						}

						case 3:
						{
							return;
						}

						case 4:
						{
							// already connected
							State = 0;
							throw new TransportException("Connection in error", Te);
						}

						default:
						{
							//TransportException te = new TransportException("Invalid state: " + state);
							State = 0;
                            throw new TransportException("Invalid state: " + State);
						}
					}
					State = 1;
					Te = null;
					Thread = new Thread(this);
					Thread.SetDaemon(true);
					lock (Thread)
					{
						Thread.Start();
						Runtime.Wait(Thread, timeout);
						switch (State)
						{
							case 1:
							{
								State = 0;
								Thread = null;
								throw new TransportException("Connection timeout");
							}

							case 2:
							{
								if (Te != null)
								{
									State = 4;
									Thread = null;
									throw Te;
								}
								State = 3;
								return;
							}
						}
					}
				}
				catch (Exception ie)
				{
					State = 0;
					Thread = null;
					throw new TransportException(ie);
				}
				finally
				{
					if (State != 0 && State != 3 && State != 4)
					{
						if (Log.Level >= 1)
						{
							Log.WriteLine("Invalid state: " + State);
						}
						State = 0;
						Thread = null;
					}
				}
			}
		}