Hi, I'm building a service application based on THttpServer. For each OnGetDocument event I'm building and returning XML. The XML building process can be lengthy and I'd like to be able to handle other requests while one is being processed.
* procedure TMainForm.HttpServer1GetDocument(Sender, Client: TObject; var Flags: THttpGetFlag);* * var* * current_connection : TMyHttpConnection;* * begin* * current_connection := TMyHttpConnection(Client);* * if CompareText(current_connection.Path, '/request_type1') = 0 then* * current_connection.AnswerString(Flags,'','application/xml; charset="utf-8"','',ProduceXML());* * end;* My method to produce XML looks like this: * function ProduceXML():string;* * var* * myQuery : TUniQuery;* * begin* * Result:= '<?xml version="1.0" encoding="utf-8"?>';* * myQuery:= TUniQuery.Create(nil);* * myQuery.Connection:= someConnection;* * myQuery.SQL.Text:= 'some sql';* * myQuery.Open;* * while not myQuery.Eof do* * begin* * (...)* * Result:= Result + some_xml;* * myQuery.Next;* * end;* * (...)* * end;* I'm not experienced with multithreading, but ICS is non blocking, so I think you already are handling most of the process, but I'd like to know the best approach to handle multiple XML building at the same time. The needed queries are created at runtime, inside the method that returns the XML string. I'm not sure what happens now when several requests come at the same time. Should I create a thread to handle ProduceXML? Thanks! -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be