有什么我们可以从导入一个好名单user32.dll,并kernel.dll在C#中使用?我是Windows API的新手,我想了解更多有关这两个库的信息.
我有这个代码,我担心它"不安全"我在使用语句结束之前使用了Dispose(),对我来说它有点不合逻辑,但它工作得很好.那么,这样安全吗?
using (FileStream stream = new FileStream(SfilePath, FileMode.Open))
{
try
{
XmlSerializer deserializer = new XmlSerializer(typeof(HighscoresViewModel));
HVM = deserializer.Deserialize(stream) as HighscoresViewModel;
}
catch (InvalidOperationException)
{
stream.Dispose();
(new FileInfo(SfilePath)).Delete();
HVM = new HighscoresViewModel();
}
}
Run Code Online (Sandbox Code Playgroud) 我知道这可能很奇怪,但我有一个计时器,我有一个事件处理程序,用于在控制台上写入的Elapsed事件,但是当我启动应用程序时,计时器正常启动,事件也正常启动.但是,结果不会显示在控制台中,除非我按下一个按钮,这使我放两个,Console.ReadKey()所以应用程序将不会终止.
这是以下代码Program.cs:
static void Main(string[] args)
{
Timer timer = new Timer(100);
timer.Elapsed += new ElapsedEventHandler(WriteOnConsole);
timer.Start();
Console.ReadKey();
Console.ReadKey();
}
static void WriteOnConsole(object source, ElapsedEventArgs e)
{
Console.WriteLine("A B C D");
}
Run Code Online (Sandbox Code Playgroud)
如果我没有提到足够的信息,请通知我.