当前位置: 首页>>代码示例>>C#>>正文


C# IProgress.setProgress方法代码示例

本文整理汇总了C#中IProgress.setProgress方法的典型用法代码示例。如果您正苦于以下问题:C# IProgress.setProgress方法的具体用法?C# IProgress.setProgress怎么用?C# IProgress.setProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProgress的用法示例。


在下文中一共展示了IProgress.setProgress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: accept

		/// <summary> A private variation on <code>accept()</code> that also has an argument
		/// indicating that the process we are waiting for is an AIR application. If
		/// it is, then we can sometimes give slightly better error messages (see bug
		/// FB-7544).
		/// 
		/// </summary>
		/// <param name="isAIRapp">if <code>true</code>, then the process we are waiting for
		/// is an AIR application. This is only used to give better error
		/// messages in the event that we can't establish a connection to
		/// that process.
		/// </param>
		private Session accept(IProgress waitReporter, bool isAIRapp)
		{
			// get timeout 
			int timeout = getPreference(SessionManager.PREF_ACCEPT_TIMEOUT);
			int totalTimeout = timeout;
			int iterateOn = 100;
			
			PlayerSession session = null;
			try
			{
				m_processDead = false;
                m_serverSocket.Server.ReceiveTimeout = iterateOn;
				
				// Wait 100ms per iteration.  We have to do that so that we can report how long
				// we have been waiting.
				System.Net.Sockets.TcpClient s = null;
				while (s == null && !m_processDead)
				{
					try
					{
                        if (m_serverSocket.Pending())
                        {
                            s = m_serverSocket.AcceptTcpClient();
                        }
                        else
                        {
                            System.Threading.Thread.Sleep(iterateOn);
                            timeout -= iterateOn;
                            if (timeout < 0) throw new IOException();
                        }
                    }
                    catch (IOException ste)
                    {
                        timeout -= iterateOn;
                        if (timeout < 0 || m_serverSocket == null || !m_serverSocket.Server.Connected)
                            throw ste; // we reached the timeout, or someome called stopListening()
                    }

					// Tell the progress monitor we've waited a little while longer,
					// so that the Eclipse progress bar can keep chugging along
					if (waitReporter != null)
						waitReporter.setProgress(totalTimeout - timeout, totalTimeout);
				}
				
				if (s == null && m_processDead)
				{
					IOException e = null;
					String detailMessage = LocalizationManager.getLocalizedTextString("processTerminatedWithoutDebuggerConnection"); //$NON-NLS-1$
					
					if (m_processMessages != null)
					{
						String commandLineMessage = m_processMessages.ToString();
						if (commandLineMessage.Length > 0)
							e = new CommandLineException(detailMessage, m_launchCommand, commandLineMessage, m_processExitValue);
					}
					
					if (e == null)
					{
						if (isAIRapp)
						{
							// For bug FB-7544: give the user a hint about what might have gone wrong.
							detailMessage += s_newline;
							detailMessage += LocalizationManager.getLocalizedTextString("maybeAlreadyRunning"); //$NON-NLS-1$
						}
						
						e = new IOException(detailMessage);
					}
					
					throw e;
				}

				/* create a new session around this socket */
				session = PlayerSession.createFromSocket(s);
				
				// transfer preferences 
				session.Preferences = m_prefs;
			}
			catch (NullReferenceException)
			{
				throw new SocketException(); //$NON-NLS-1$
			}
			finally
			{
				m_processMessages = null;
				m_launchCommand = null;
			}
			
			return session;
		}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:100,代码来源:PlayerSessionManager.cs


注:本文中的IProgress.setProgress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。