.Net异步套接字操作限制?(.Net asynchronous socket operations limit?)
待处理的异步操作是否应该谨慎使用?
我有一大堆连接的TcpClients,我不期待输入,但为了防止一个行为不端,我需要保持输入缓冲区为空。 如果每个连接的客户端都有一个BeginRead(),它会无限期地保持打开状态,那有什么危害吗? 当客户端最终关闭时将调用回调,如果!asyncResult.IsCompleted我可以退出它。
我不知道开始阅读多少字节,但我相信我可以共享一个缓冲区。 输入到缓冲区限制可能只是在流中,未读。 有没有更好的方法来有效地丢弃,禁止或等待流中数据的可用性?
否则我需要轮询可用的数据。
谢谢!
Are pending asynchronous operations are precious resource that should be used sparingly?
I have a slew of connected TcpClients that I'm not expecting input from, but just in case one is misbehaving, I need to keep the input buffers empty. If I have a BeginRead() for each connected client that just stays open indefinitely, is there any harm? The callback will be called when the client is eventually closed and I can just return out of it if !asyncResult.IsCompleted.
I wouldn't know how many bytes to begin reading, though I believe I could share one buffer. Input up to that buffer limit could just sit in the stream, unread. Is there a better way to efficiently discard, disallow, or WAIT on the availability of data in a stream?
Otherwise I need to poll for data available.
Thanks!
原文:https://stackoverflow.com/questions/5143716
最满意答案
我认为你需要改变你的最后一行
ActiveWorkbook.Close savechanges:=False
至
ActiveWorkbook.Close savechanges:=True extwbk.Close savechanges:=False
否则,我认为当您使用
ActiveWorkbook.saveas
保存新工作簿时,它会立即成为活动工作簿I think you need to change your last line from
ActiveWorkbook.Close savechanges:=False
To
ActiveWorkbook.Close savechanges:=True extwbk.Close savechanges:=False
Otherwise I think when you save the new workbook using
ActiveWorkbook.saveas
- it immediately becomes the active workbook
相关问答
更多-
您需要激活Activate每个工作表,然后再将它们打印为pdf。 尝试这个 ' Begin the loop. For Each wsA In wbA.Sheets wsA.Activate 'replace spaces and periods in sheet name strName = Replace(wsA.Name, " ", "") strName = Replace(strName, ".", "_") ...
-
您收到错误91,因为您在没有Set关键字的情况下分配对象引用,此处: wbout = Workbooks.Open(folderin) 但是一旦修复了,你就会收到错误438,因为你指的是一个未在Excel.Workbook界面上定义的成员: Set wsin = wbin.Worksheet("P3 PayOuts") 这是Worksheets ,而不是Worksheet 。 通过使用我管理的开源VBIDE加载项目Rubberduck进行检查,可以避免这两个错误(可能还有更多 - 你有未使用的变量,然后 ...
-
我认为你需要改变你的最后一行 ActiveWorkbook.Close savechanges:=False 至 ActiveWorkbook.Close savechanges:=True extwbk.Close savechanges:=False 否则,我认为当您使用ActiveWorkbook.saveas保存新工作簿时,它会立即成为活动工作簿 I think you need to change your last line from ActiveWorkbook.Close savecha ...
-
正如您在评论中指出的那样,您无法将XlsxWriter工作簿对象传递给pandas to_excel() 。 作为一种解决方法,您可以使用空数据框创建工作表,然后访问下面的XlsxWriter工作簿和工作表对象。 然后,您可以通过pandas界面添加额外的工作表。 这是一个基于您的代码的小工作示例: import pandas as pd # Create an pandas excel writer based on xlsxwriter. writer = pd.ExcelWriter('test.x ...
-
只需用你自己的提示包装它: If Not ThisWorkbook.Saved Then If MsgBox("Do you want to save the file before continuing?",vbYesNo,"Save?") = vbYes Then ThisWorkbook.Save End If End If Just wrap it with your own prompt: If Not ThisWorkbook.Saved Then ...
-
准备新的工作簿以进行保存(Preparing a new workbook for save)[2023-06-01]
我希望这是你正在寻找的: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) 'do your prepping If SaveAsUI Then 'do something (like open your own UI) End If 'save workbook Cancel = True 'cancel the original save ac ... -
Excel工作簿保存为.pdf(Excel workbook to Save As .pdf)[2023-07-09]
试试这个(我没有打印机设置,所以无法测试) fName = ActiveWorkbook.FullName If InStr(fName, ".") > 0 Then fName = Left(fName, InStrRev(fName, ".") - 1) ActiveWorkbook.ExportAsFixedFormat xlTypePDF, fName & ".pdf", _ xlQualityStandard, , , , ... -
在尝试保存之前添加Application.DisplayAlerts = False 。 保存完毕后,请记得再回到True状态。 Add Application.DisplayAlerts = False before you try and save. Remember to turn in back to True after you've saved.
-
如何从工作簿B中调用Workbook_Open on Workbook A?(How can I call Workbook_Open on Workbook A from Workbook B?)[2022-04-08]
Workbook_Open是一个私有子。 你不能直接打电话。 我可以提供选项3:将Workbook_open的代码复制到工作簿B中的子项中。然后,您可以将其称为公共,然后您可以将其调用以进行模拟。 此外,如果需要考虑损坏,请创建工作簿A的副本以用于测试。 然后如果它被破坏,原件仍然可用。 Workbook_Open is a private sub. You cannot call it directly. May I offer Option 3: Copy the code from Workbook_ ... -
用参数打开工作簿(Open workbook with arguments)[2022-01-23]
我建议的两个选项,简而言之: 在您打开的工作簿中,将其添加到ThisWorkbook模块: Public OpenedInCode as Boolean 您的调用工作簿需要打开工作簿,然后使用类似的东西 With Workbooks("workbook name.xlsm") .OpenedInCode = True .RunAutoMacros xlAutoOpen End With 然后Auto_Open代码需要检查此值。 如果是False ,则用户打开它; 如果True ,则您的其他工作 ...