Пример #1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         FindTheHid();
         _queryThread = new QueryThread(this);
         _queryThread.Start();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #2
0
        /// <exception cref="UnknownHostException"></exception>
        internal static NbtAddress[] LookupServerOrWorkgroup(string name, IPAddress svr)
        {
            Sem         sem  = new Sem(2);
            int         type = NbtAddress.IsWins(svr) ? unchecked (0x1b) : unchecked (0x1d);
            QueryThread q1X  = new QueryThread(sem, name, type, null, svr);
            QueryThread q20  = new QueryThread(sem, name, unchecked (0x20), null, svr);

            q1X.SetDaemon(true);
            q20.SetDaemon(true);
            try
            {
                lock (sem)
                {
                    q1X.Start();
                    q20.Start();

                    while (sem.Count > 0 && q1X.Ans == null && q20.Ans == null)
                    {
                        Runtime.Wait(sem);
                    }
                }
            }
            catch (Exception)
            {
                throw new UnknownHostException(name);
            }
            if (q1X.Ans != null)
            {
                return(q1X.Ans);
            }
            if (q20.Ans != null)
            {
                return(q20.Ans);
            }
            throw q1X.Uhe;
        }
Пример #3
0
		/// <exception cref="UnknownHostException"></exception>
		internal static NbtAddress[] LookupServerOrWorkgroup(string name, IPAddress svr)
		{
			Sem sem = new Sem(2);
			int type = NbtAddress.IsWins(svr) ? unchecked(0x1b) : unchecked(0x1d);
			QueryThread q1X = new QueryThread(sem, name, type, null, svr
				);
			QueryThread q20 = new QueryThread(sem, name, unchecked(0x20), null, svr);
			q1X.SetDaemon(true);
			q20.SetDaemon(true);
			try
			{
				lock (sem)
				{
					q1X.Start();
					q20.Start();
					while (sem.Count > 0 && q1X.Ans == null && q20.Ans == null)
					{
						Runtime.Wait(sem);
					}
				}
			}
			catch (Exception)
			{
				throw new UnknownHostException(name);
			}
			if (q1X.Ans != null)
			{
				return q1X.Ans;
			}
		    if (q20.Ans != null)
		    {
		        return q20.Ans;
		    }
		    throw q1X.Uhe;
		}