本文整理汇总了C++中TimeSpan类的典型用法代码示例。如果您正苦于以下问题:C++ TimeSpan类的具体用法?C++ TimeSpan怎么用?C++ TimeSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimeSpan类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: UpdateProcessStats
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
示例2: PerformProcessActions
void CMainDlg::PerformProcessActions(PatchedProcess &proc, TimeSpan &runTime, bool *pPatchingStarted)
{
if ((proc.State == PatchProcessTerminated) || (proc.State == Unpatched))
CleanupProcessEntry(proc);
else
{
if (proc.hLogPipe == INVALID_HANDLE_VALUE)
proc.hLogPipe = CreateLogPipe(proc.PID);
}
if (proc.State == PatchPending)
{
if (runTime.GetTotalSeconds() > m_Params.PatchDelay)
{
bool started = InitiatePatching(proc);
if (pPatchingStarted)
*pPatchingStarted = started;
}
}
if (proc.State == PatchInProgress)
{
if (WaitForSingleObject(proc.hRemoteThread, 0) == WAIT_OBJECT_0)
{
DWORD dwCode = 0;
GetExitCodeThread(proc.hRemoteThread, &dwCode);
if (dwCode)
proc.State = PatchInProgress2;
else
proc.State = PatchFailed;
CloseHandle(proc.hRemoteThread);
proc.hRemoteThread = INVALID_HANDLE_VALUE;
}
}
if ((proc.State == PatchInProgress2) || (proc.State == PatchSuccessful))
{
if (proc.pStatus)
{
switch (proc.pStatus->PatchErrorPlus1 - 1)
{
case ERROR_SUCCESS:
proc.State = PatchSuccessful;
break;
case -1:
proc.State = PatchInProgress2;
break;
default:
proc.State = PatchFailed;
}
}
if (proc.pStatus->ProtocolMismatchStatus)
{
proc.State = ProtocolMismatch;
WORD expected = HIWORD(proc.pStatus->ProtocolMismatchStatus), found = LOWORD(proc.pStatus->ProtocolMismatchStatus);
proc.pStatus->ProtocolMismatchStatus = 0;
TCHAR tsz[256];
_sntprintf(tsz, __countof(tsz), _T("Warning! KDBAZIS.DLL version %x.%02x was loaded by virtual machine, while version %x.%02x was expected. Debugging functions disabled!"),
HIBYTE(found), LOBYTE(found), HIBYTE(expected), LOBYTE(expected));
MessageBox(tsz, _T("Invalid KDBAZIS.DLL version"), MB_ICONWARNING);
}
}
if (proc.State == UnpatchInProgress)
{
if (WaitForSingleObject(proc.hRemoteThread, 0) == WAIT_OBJECT_0)
{
CloseHandle(proc.hRemoteThread);
proc.hRemoteThread = INVALID_HANDLE_VALUE;
proc.State = Unpatched;
UpdateLog(proc);
CleanupProcessEntry(proc);
}
}
UpdateLog(proc);
}
开发者ID:BBLN,项目名称:VirtualKD,代码行数:77,代码来源:MainDlg.cpp
示例3: Sleep
/**
* Signals the current thread to stop processing for the specified time span.
*
* @param timeSpan The amount of time to stop processing.
*/
static void Sleep(const TimeSpan& timeSpan) { StackTrace trace(__METHOD__, __FILE__, __LINE__);
if (timeSpan > TimeSpan::Zero()) {
msleep((uint32_t) timeSpan.TotalMilliseconds());
Idle += timeSpan;
}
}
开发者ID:bakerface,项目名称:nitrus,代码行数:11,代码来源:Thread.hpp
示例4: DateTime
DateTime DateTime::operator-(const TimeSpan& span) {
return DateTime(unixtime()-span.totalseconds());
}
开发者ID:radikalbytes,项目名称:PCF8523,代码行数:3,代码来源:PCF8523.cpp
示例5: Utilization
/**
* Returns the thread utilization.
*
* @return A value in between zero and one, where zero means the thread was completely idle, and one means the thread was completely busy.
*/
static double Utilization() { StackTrace trace(__METHOD__, __FILE__, __LINE__);
double duration = (DateTime::Utc() - Started).TotalMilliseconds();
return (duration - Idle.TotalMilliseconds()) / duration;
}
开发者ID:bakerface,项目名称:nitrus,代码行数:9,代码来源:Thread.hpp
注:本文中的TimeSpan类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论