Windows 控制台中的初始事件

发布于 2024-08-03 04:49:37 字数 198 浏览 1 评论 0原文

我正在创建一个用 VB.NET 编写的 Windows 控制台应用程序,并且有一些进程在应用程序的生命周期内只需要调用一次。如果是 ASP.NET 应用程序,我将它们放在 Global.asax.vb 文件的 Appliction_Start 方法中。由于没有用于控制台应用程序的 Global.asax.vb,是否有一个我可以处理的事件,允许我在调用 Main 之前调用我的函数?

I'm creating a Windows Console application written in VB.NET and I have a few processes that need to be called only once during the lifetime of the application. If it was an ASP.NET application, I put these in the Appliction_Start method of the Global.asax.vb file. Since there isn't a Global.asax.vb for Console applications, is there an event I could handle that allows me to call my functions before Main is called?

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

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

发布评论

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

评论(2

烟花肆意 2024-08-10 04:49:37

在 main 中首先调用它们是否有问题?

Is there a problem with just calling them first in main?

奶茶白久 2024-08-10 04:49:37

Main 是第一个方法,您可以在其中获取所需的信息/初始化全局内容。
为什么你需要更早的一点?与 Application_Start 唯一不同的是,不会自动调用其他方法(与打开站点并执行代码的 Web 应用程序不同)。

Main is the first method where you can grab the needed information / inizialize global stuff.
Why would you need an earlier point? The only thing that is different to Application_Start is that no other method is called automatically (unlike in a web application where the site is opened and the code executed).

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