Note that there are some explanatory texts on larger screens.

plurals
  1. POCan this code be improved with the use of multithreading?
    primarykey
    data
    text
    <p>I have a simple Windows service, which runs only once per day. It performs some queries in database, generates appropriate html content (tables, divs, ...) and sends it in body of an e-mail to multiple recipients.</p> <p>The body of the e-mail is created like this:</p> <pre><code>private static string GenerateBody() { using (var stringWriter = new StringWriter()) using (var htmlWriter = new HtmlTextWriter(stringWriter)) { htmlWriter.RenderBeginTag("html"); htmlWriter.RenderBeginTag(HtmlTextWriterTag.Head); htmlWriter.WriteLine("&lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /&gt;"); htmlWriter.RenderEndTag(); htmlWriter.RenderBeginTag("body"); htmlWriter.Write( new StringBuilder() .Append(OverviewParagraph.GenerateHTMLContent()) .Append(PackageWeightParagraph.GenerateHTMLContent()) .Append(BoxWeightParagraph.GenerateHTMLContent()) .Append(CodeQualityParagraph.GenerateHTMLContent()) .Append(ChecksParagraph.GenerateHTMLContent()) .ToString() ); htmlWriter.RenderEndTag(); htmlWriter.RenderEndTag(); return stringWriter.ToString(); } } </code></pre> <p>All the <code>GenerateHTMLContent</code> methods are pretty much the same - they execute a query in my database, build an HTML table with the help of a HTMLTextWriter and return the table as a string. </p> <p>Can this code be improved with the use of multithreading or maybe async-await pattern? The code in question is where I append lines to the StringBuilder object.</p> <p>EDIT: I asked the question because I never worked with multithreading before, just wanted to know if it is possible. Besides, the program runs fast enough now.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload