我有一个场景,其中有一个工作方法(DoWork()),该方法由Web服务连续调用。
此工作方法使用(writeToFile())将数据写入文件,我需要在2种情况下将其写入文件。>
a)当记录数达到500时OR
b)距上一个文件已写入2分钟
我的示例代码如下:
public override void DoWork() { //-- This worker method is called continuously by the webservice List<string> list1 = new List<string>(); List<string> list2 = new List<string>(); int count =0; //--- Some code that writes the RawData list1.Add(rawData); If(list1.Count<=500) { list2=list1; count = WriteToFile(list2); } } public static int WriteToFile(List<string> list) { //-- The writing of File Should happen when 500 records reached OR 2 mins passed. // ---- Logic for writing the list file using the Streamwriter is working fine }
我需要逻辑检查是否
列表中达到500条记录或与上一个相比过去了2分钟生成的文件,
只有这样,文件才应该发生。
谢谢:)
我有一个场景,其中有一个工作方法(DoWork()),该方法由Web服务连续调用。此工作方法使用(writeToFile())将数据写入文件,我需要...
为了使它更具可读性,我会在这里使用一些帮助器...时间检查: