- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我想知道系统最后一次启动是什么时候。
Environment.TickCount 可以工作,但由于 int 的限制,它会在 48-49 天后中断。
这是我一直在使用的代码:
Environment.TickCount & Int32.MaxValue
有人知道 long type return 吗?
我用它来了解系统的空闲时间:
public static int GetIdleTime()
{
return (Environment.TickCount & Int32.MaxValue)- (int)GetLastInputTime();
}
/// <summary>
/// Get the last input time from the input devices.
/// Exception:
/// If it cannot get the last input information then it throws an exception with
/// the appropriate message.
/// </summary>
/// <returns>Last input time in milliseconds.</returns>
public static uint GetLastInputTime()
{
LastInputInfo lastInPut = new LastInputInfo();
lastInPut.BlockSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(lastInPut);
if (!GetLastInputInfo(ref lastInPut))
{
throw new Exception(GetLastError().ToString());
}
return lastInPut.Time;
}
最佳答案
以下代码检索自系统启动以来的毫秒数(调用 unmanged API)。我测量了该互操作操作的性能成本,它与 StopWatch() 完全相同(当然,它不会检索自系统直接启动以来的时间)。
using System.Runtime.InteropServices;
...
[DllImport("kernel32.dll") ]
public static extern UInt64 GetTickCount64();
...
var tickCount64 = GetTickCount64();
https://msdn.microsoft.com/de-de/library/windows/desktop/ms724411(v=vs.85).aspx
关于c# - Environment.TickCount 是不够的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4645171/
killer = killer.Replace("(", "\("); 试图在大括号前放置'\',它显示“错误1无法识别的转义序列” 我还尝试在其前面加上“@”,但这会导致两个反斜杠。 最佳答案 使用
我创建了一个包含书籍的小型数据库,并试图在 C# 中使用正则表达式获取书名、作者和书籍年份,但出现错误。 数据库看起来像这样: Eragon // Christopher Paolini // 200
当我尝试编译时 scalala我得到一个 OutOfMemoryError: > compile [info] [info] == compile == [info] Source analysi
这个问题在这里已经有了答案: Regex escape with \ or \\? (5 个答案) 关闭 4 年前。 我遇到了 ) 不够的错误,但据我所知,我已经得到了所有的 )。 行获取错误: s
我正在尝试使用 pthread_create 函数创建一个线程。电话是这样的:res pthread_create(&threadID, &atributte, function, argument)
我需要能够遍历我的整个对象图并记录所有成员字段的所有内容。 例如:对象 A 具有对象 B 的集合,对象 B 具有对象 C 的集合,并且 A、B、C 上有附加字段,等等。 Apache Commons
我的 create.jspx 中有一行,如下所示: 此字段显示一个框,其中的行由 2 个实体之间的关系 @ManyToMany 填充。 现在的问题是,第一个实体只有一个填充此框的 String 属性
ctags -R dirName, vim -t Tags 非常强大,因为在这两个命令之后,你现在可以在该项目的代码之间导航,例如你可以使用 :tag functionName 跳转到某个函数的代码,
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: iphone 5 simulator - Cannot click on bottom of screen?
我有一个庞大的关键字表,一个关键字出现在一个外键中,例如 key=2 word=download key=3 word=download key=4 word=game 目前我有另一个字段称为字母索引
这个问题在这里已经有了答案: How to change stack size for a .NET program? (4 个答案) 关闭 7 年前。 我在 bmp 中有以下用于“blob 填充”
我是一名优秀的程序员,十分优秀!