消防和忘记DB记录与ASP.NET [英] Fire and forget DB logging with ASP.NET

查看:158
本文介绍了消防和忘记DB记录与ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MySQL与ASP.NET和记录一些用户请求到数据库。是否有可能做到这一点的日志记录,而不会阻塞主网页的生命周期?我读过一些异步。使用ADO.NET但大部分都集中在等待从异步答复。请求。有没有办法实现这个而没有从数据库中等待答复?

I am using MySQL with ASP.NET and log some user request to DB. Is it possible to do this logging without blocking the main page life cycle? I've read about some async. with ADO.NET but most are focused on waiting a reply from the async. request. Is there a way to implement this without ever waiting a reply from the DB?

推荐答案

对于一个发射后不管的情况,你可以生成一个新的线程,并不会阻塞主线程等待它完成:

For a fire and forget scenario you could spawn a new thread and never block the main thread waiting for it to complete:

new Thread(() => {
    // use ADO.NET to do the database query
}).Start();

这篇关于消防和忘记DB记录与ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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