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


C++ TimeSpan::ToString方法代码示例

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


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

示例1: GenTimeSpanFromDays

void GenTimeSpanFromDays( double days )
{
   
   // Create a TimeSpan object and TimeSpan string from 
   // a number of days.
   TimeSpan interval = TimeSpan::FromDays( days );
   String^ timeInterval = interval.ToString();
   
   // Pad the end of the TimeSpan string with spaces if it 
   // does not contain milliseconds.
   int pIndex = timeInterval->IndexOf( ':' );
   pIndex = timeInterval->IndexOf( '.', pIndex );
   if ( pIndex < 0 )
      timeInterval = String::Concat( timeInterval, "        " );

   Console::WriteLine( "{0,21}{1,26}", days, timeInterval );
}
开发者ID:Ireneph,项目名称:samples,代码行数:17,代码来源:fromdays.cpp

示例2: UpdateProcessInfo

void CMainDlg::UpdateProcessInfo()
{
	DateTime now = DateTime::Now();
	int idx = m_ListView.GetSelectedIndex();
	for (unsigned i = 0; i < (unsigned)m_Processes.size(); i++)
	{
		PatchedProcess &proc = m_Processes[i];
		if (proc.StillRunning)
			UpdateProcessStats(proc, proc.PID, m_ProcessorCount);

		if (!proc.StillRunning)
			proc.State = PatchProcessTerminated;
		TimeSpan runTime = now - proc.StartTime;
		if (!proc.StillRunning)
			runTime = proc.StopTime - proc.StartTime;
		m_ListView.AddItem(i, 2, runTime.ToString().c_str());
		TCHAR tsz[128];
		_sntprintf_s(tsz, __countof(tsz), _TRUNCATE, _T("%d%%"), proc.CpuUsage / 10);
		m_ListView.AddItem(i, 3, tsz);
		bool patchStarted = false;
		PerformProcessActions(proc, runTime, &patchStarted);

		if (patchStarted)
			m_ListView.SelectItem(i), idx = i;

		if (idx == i)
		{
			if (proc.LogChanged)
			{
				SetDlgItemText(IDC_EDIT1, proc.Log.c_str());
				SendDlgItemMessage(IDC_EDIT1, WM_VSCROLL, SB_BOTTOM, 0);
				proc.LogChanged = false;
			}
			if (proc.State == PatchSuccessful)
			{
				m_StatsView.EnableWindow(TRUE);
				DisplayStats(proc);
			}
			else
				m_StatsView.EnableWindow(FALSE);
		}

		switch (proc.State)
		{
		case PatchInProgress:
		case PatchInProgress2:
			m_ListView.SetItem(i, 0, LVIF_IMAGE, NULL, ProcessPending, 0, 0, 0);
			m_ListView.AddItem(i, 4, _T("loading..."));
			break;
		case UnpatchInProgress:
			m_ListView.SetItem(i, 0, LVIF_IMAGE, NULL, ProcessPending, 0, 0, 0);
			m_ListView.AddItem(i, 4, _T("unloading..."));
			break;
		case PatchPending:
			m_ListView.SetItem(i, 0, LVIF_IMAGE, NULL, ProcessPending, 0, 0, 0);
			m_ListView.AddItem(i, 4, _T(""));
			break;
		case PatchSuccessful:
			m_ListView.SetItem(i, 0, LVIF_IMAGE, NULL, ProcessPatched, 0, 0, 0);
			if (proc.pStatus)
			{
				const KdClientStatus &status = *proc.pStatus;
				m_ListView.AddItem(i, 4, status.PipeName + 9);
				proc.PipeName = status.PipeName;

#ifdef _DEBUG
				{
					wchar_t wszT[MAX_PATH] = {0,};
					GetVMPipeNameW(proc.PID, wszT, __countof(wszT), true);
					ASSERT(!wcscmp(wszT, status.PipeName));
				}
#endif

				_sntprintf_s(tsz, __countof(tsz), _TRUNCATE, _T("%d/%d"), status.PacketsSent, status.PacketsReceived);
				m_ListView.AddItem(i, 5, tsz);
				_sntprintf_s(tsz, __countof(tsz), _TRUNCATE, _T("%d"), status.ResyncCount);
				m_ListView.AddItem(i, 6, tsz);
				m_ListView.AddItem(i, 7, status.OSDetected ? _T("yes") : _T(""));
				m_ListView.AddItem(i, 8, status.DebuggerConnected ? _T("yes") : _T(""));
				_sntprintf_s(tsz, __countof(tsz), _TRUNCATE, _T("%d"), proc.PollRate);
				m_ListView.AddItem(i, 9, tsz);
				if (!proc.idDebuggerProcess)
				{
					if ((m_Params.AutoInvokeDebugger && status.PipeName[0]) && (!m_Params.WaitForOS || status.OSDetected))
					{
						RunDebugger(i);
					}
				}
			}
			else
			{
				m_ListView.AddItem(i, 4, _T("loading..."));
				m_ListView.AddItem(i, 7, _T(""));
				m_ListView.AddItem(i, 8, _T(""));
			}
			break;
		case PatchFailed:
			m_ListView.SetItem(i, 0, LVIF_IMAGE, NULL, ProcessFailed, 0, 0, 0);
			m_ListView.AddItem(i, 4, _T(""));
			break;
//.........这里部分代码省略.........
开发者ID:BBLN,项目名称:VirtualKD,代码行数:101,代码来源:MainDlg.cpp


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