本文整理汇总了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;
}