Mysql连接在C Sharp中的应用 [英] Mysql connection in c sharp application

查看:117
本文介绍了Mysql连接在C Sharp中的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我对mysql连接有疑问,在我的c锋利应用程序中,我将用户登录状态存储在数据库中,并使用计时器检查状态更改,该计时器在100毫秒的延迟时间内滴答.数据库检查功能使用计时器进行调用.是否由于继续对应用程序进行数据库访问而发生任何性能问题?

感谢

Hello,

I have a doubt about mysql connction, in my c sharp application I store the user login status in database and i check the status change by using a timer, which ticks in 100 ms delay.The database check function invokes using the timer. Is there any performance problem occurred due to this continues database access to my application?

thanks

推荐答案

我不明白为什么需要如此频繁地这样做.在某些情况下,网络延迟和服务器负载可能意味着应用程序正在尝试在最后一次更新完成之前更新状态.

为什么根本需要记录状态? [我显然不知道您要做什么,所以您可能有充分的理由,只是很好奇.)

用户首次登录时,如果有任何记录,请在数据库中记录一个令牌,然后每10-30秒或每隔30秒钟更新一次状态.

在后台工作线程中运行此命令.在数据库中设置令牌的到期时间,然后只需确保您的应用程序在到期时间之前更新此令牌时间即可.这样,如果您的会话/应用程序失败,然后令牌将过期,如果您的应用程序随后重新启动并轮询令牌,并且令牌已过期,则用户必须再次登录.

然后,您还可以使用管理员角色杀死令牌等,从而从应用程序中强制删除会话. [同样,这种情况取决于您要实现的目标以及多用户模型的工作方式]

最重要的是,我不会尝试像100ms那样频繁地轮询.
I don''t see why you need to do it so frequently. There are probably occasions where network latency and server load would mean the app is trying to update the status before the last update has finished.

Why do you need to record the status at all? [I obviously don''t know what you are trying to do, so you may have good cause, just curious that''s all).

If anything when the user logs in the first time, record a token in the database, and then only update the status every 10-30 seconds or whatever.

Run this in a background worker thread. Set an expiration time for the token in the database, and then just make sure your application updates this token time before the expiry time. That way if your session/app fails and then then the token will expire, if you app then is restarted and polls for the token, and it is expired, the user must then login again.

You can also then use admin roles to kill tokens etc, forcefully removing sessions from the app. [again, this sort of thing is dependant on what exactly you are trying to achieve and how your multi-user model works]

Bottom line, i would not be trying to poll as frequently as 100ms.


是的.如果您的应用程序每秒以10次往返服务器的速度来检查诸如登录状态之类的内容,则肯定会带来性能开销.

您真的不需要这样做吗?
Yes. If your application is going back a forth to a server 10 times a second to check on something like login status you will definitely incur a performance overhead.

You really shouldn''t need to do this?


数据库每100ms命中一次显然不是一个好主意.

是Web应用程序还是Windows?为什么您要进行此类检查?
database hit on every 100ms is obviously not a good idea.

Is it web application or windows ? Why u want to do such checks ?


这篇关于Mysql连接在C Sharp中的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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