在关闭请求之前从服务器端读取数据

时间:2013-02-25 10:11:18

标签: c# jquery xmlhttprequest xmlwriter

在下面的代码中,我有 tempGsContact ,对象将其作为方法的值,然后我解析为 XML writer ,如图所示。我需要读取检索到客户端的每个对象,而无需等待所有对象完成后。我能做些什么来实现这一目标?我希望我的问题很明确!

using (XmlWriter xmlWriter = XmlWriter.Create(HttpContext.Current.Response.OutputStream, xmlWriterSettings))
                {
     for (int count = 0; count < length - 1; count++)
      {
                tempGsContact = ConvertStringToContactObject(_fileContacts[count]);
               if (tempGsContact != null)
                {
                   tempGsContact.ContactSubInfo.Sort(new Comparison<GSContactInfo>((x, y)                 => string.Compare(x.ContactPropertyTitle, y.ContactPropertyTitle)));                                           
                 _fileContacts = null;
                   #region Convert Contact To XML Format                                            
                  xmlWriter.WriteStartElement("Contact");
                  xmlWriter.WriteAttributeString("Name", tempGsContact.DisplayName);
                  xmlWriter.WriteEndElement();
                  xmlWriter.Flush();
                  #endregion                                          
                }
       }
}

0 个答案:

没有答案