Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
npgsql 的默认连接超时值以秒为单位,但我想以毫秒为单位设置,因为我需要它小于 1 秒。
ps 我尝试设置小数(例如 0.5),但它不起作用
据我所知,您将无法在该提供商处使用小于一秒的测量值,因此您几乎没有选择余地。
1) 找到另一个允许在不到一秒的时间内连接超时的提供商。
2) 如果连接建立得不够快,使用计时器会引发异常。我认为您需要使用线程技术才能使其工作。我发现本指南“http://www.albahari.com/threading/”对我很有帮助。
3)使用连接池并保留一些已经连接的连接,这样您就不必重新建立连接。
祝你好运