C# 中的状态事件

发布于 2024-08-17 13:21:32 字数 237 浏览 11 评论 0原文

.net(c#) 或任何库中是否有任何有状态事件机制可以帮助我维护所触发事件的状态。

有状态我的意思是触发时的事件被序列化到持久存储。如果系统由于某种原因发生故障,那么当它被买回来时,就会拾取序列化状态,然后再次触发它。

我也在查看计划的事件 - 在这种情况下,有状态事件可以委托给未来的时间,并且保证在那时被触发,即使系统在其间的任何时间被购买。

.net中有类似的东西吗?

Are there any stateful eventing mechanisms in .net(c#) or any libraries that will help me maintain a state for the events fired

By stateful I mean an event when fired is serialized to a persistent storage. If the system fails for some reason and then when it is bought back picks up the serialized state and then fires it again.

I am also looking at scheduled events too - In this case the stateful event can be delegated to a future time and will be guaranteed to be fired at that time even if the system was bought down anytime in between.

Is there anything like this in .net?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小矜持 2024-08-24 13:21:32

虽然有一点学习曲线,但 Windows Workflow Foundation (WF) 正是这样做的。工作流具有可能涉及引发或处理事件的活动,并且在工作流中的各个点,整个工作流的状态可以被序列化。它支持开箱即用的 SQL Server,但您可以扩展持久层。当工作流程从序列化恢复时,它们将从中断处继续。

值得注意的是,不鼓励对当前版本的 WF 进行任何认真的投资,因为他们在 .NET 4.0 中完全重写了它,如果您没有对当前版本进行投资,您可能应该从它开始。

There's a bit of a learning curve but Windows Workflow Foundation (WF) does exactly this. Workflows have activities which can involve raising or handling events and at various points in the workflow, the state of the whole workflow can be serialized. It supports SQL server out of the box but you can extend the persistence layer. When workflows are resumed from serialization they pick up where they left off.

It's worth noting that any serious investment in the current version of WF is discouraged because they completely rewrote it in .NET 4.0 and you should probably start with that if you don't have an investment in the current version.

烛影斜 2024-08-24 13:21:32

虽然从技术上讲不是有状态事件机制,但 Windows Workflow Foundation 包含许多功能处理这些特定类型的情况。

特别是,它具有用于将工作状态序列化到存储、处理故障以及通过外部事件恢复长时间运行的进程的例程。

Although not technically a stateful event mechanism, Windows Workflow Foundation contains many features to handle these specific types of situations.

In particular, it has routines in place for serializing the work state to storage, handling failures, and recovery of long running processes with external events.

酸甜透明夹心 2024-08-24 13:21:32

您也许可以使用 PostSharp 做一些事情。

You might be able to do something with PostSharp.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文