备份停电 [英] Backup for power outages

查看:62
本文介绍了备份停电的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的我是编程的新手,所以请耐心等待我,我的程序是14天的循环C#

如何在程序中保存状态。

就像电源耗尽一样,所以它会在它停止的时候开始备份。

第一次我打算通过硬件,备用电池这样做。我想这个做软件可能会遇到很多麻烦,问题并没有什么坏处。

OK I''m new to programming, so bear with me here, my program is in a 14 day loop C#
How would I go about saving the state within the program.
Like if the power went out, so it would start back up at the point it left off.
At 1st I was going to do this via hardware,backup battery.I thought this might be a lot of trouble doing it software,well it doesn''t hurt to ask.

推荐答案

在软件中执行此操作的问题在于,如果需要的话大量的时间,很有可能它会在电源出现故障时执行!



你可以做一些事情来恢复你的最后状态(例如崩溃Chrome ,它提供了重新加载你最后显示的页面)所有你要做的就是确保你写一个不同的文件,并且不要删除旧文件,直到新的文件被刷新到磁盘。只是要小心你的写入频率 - 这样做的应用程序经常非常非常烦人! (但是那些情况可能更糟 - 这是一个很好的平衡)。



如果你需要它安全,外部UPS是一个好主意 - 你可以通过USB连接获得它们,以触发大规模保存并准备好干活的事件。考虑到他们可以拯救你的其他麻烦,它们并不贵。您甚至可能会发现它们比您在添加代码和测试时花费的时间更便宜...
The problem with doing it in software is that if it takes any significant amount of time, there is a good chance that it will be executing when the power fails!

You can do something to recover your last state (crash Chrome for example, and it offers to reload your last displayed pages) all you have to do is make sure you write to a different file and do not remove the old one until the new one has been flushed to disk. Just be careful with your frequency of writes - applications which do this too often can be very, very annoying! (But ones which don''t can be even worse - it''s a fine balance).

If you need it properly safe, the an external UPS is a good idea - you can get them with a USB connection to trigger a mass-save-and-get-ready-to-die-cleanly event. They aren''t that expensive, considering how much other hassle they can save you! You may even find they are cheaper than your time spent in adding the code and testing it...


感谢我的想法,虽然程序很简单但不会让它变得简单它的备份程序,最好通过硬件来完成。
Thanks just what I thought, although the program is simple that wont make it simple to make a backup program for it, better to do it via hardware.


这篇关于备份停电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆