# C1.C1Preview.C1MultiDocument.DoEvents

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_C1Preview_C1MultiDocument_DoEvents_" data-uid="C1.C1Preview.C1MultiDocument.DoEvents*">DoEvents Property
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_C1Preview_C1MultiDocument_DoEvents_" data-uid="C1.C1Preview.C1MultiDocument.DoEvents*"></a>
<h4 id="C1_C1Preview_C1MultiDocument_DoEvents" data-uid="C1.C1Preview.C1MultiDocument.DoEvents">DoEvents</h4>
<div class="markdown level1 summary"><p>Gets or sets a value indicating whether the current <a class="xref" href="C1.C1Preview.C1MultiDocument.html">C1MultiDocument</a>
should handle Windows messages while generating.</p>
<p>The default value is false.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public bool DoEvents { get; set; }</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Property DoEvents As Boolean</code></pre>
</div>
<h5 id="C1_C1Preview_C1MultiDocument_DoEvents_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Setting this property to true allows users to resize forms, click buttons, etc. while documents are 
being generated. This makes applications more responsive, and is necessary if you want to provide a
"Cancel" button to stop the document generation (otherwise the user wouldn't be able to click the
button until the generation is complete).</p>
<p>Setting this property to false will cause documents to generate slightly faster.</p>
</div>
<h5 id="C1_C1Preview_C1MultiDocument_DoEvents_examples">Examples</h5>
<p>The code below implements "Generate" and "Cancel" buttons attached to a <a class="xref" href="C1.C1Preview.C1PrintDocument.html">C1PrintDocument</a>.</p>
<p>The "Generate" button checks whether the document is busy before starting to generate it.
This is necessary because the user could click the "Generate" button several times in a row, before the document got a 
chance to finish generating. (Calling the <a class="xref" href="C1.C1Preview.C1MultiDocument.Generate.html#C1_C1Preview_C1MultiDocument_Generate">Generate()</a> method while the component is busy throws an 
exception.)</p>
<p>The "Cancel" button checks whether the document is currently generating, and sets the <a class="xref" href="C1.C1Preview.C1MultiDocument.Cancel.html#C1_C1Preview_C1MultiDocument_Cancel">Cancel</a> 
property to true if it is.</p>
<pre><code class="lang-csharp">_doc.DoEvents = true;

private void Generate_Click(object sender, EventArgs e)
{
   if (_doc.BusyState != BusyStateEnum.Ready)
       Console.WriteLine("Cannot generate now, document is busy");
   else 
       _doc.Generate();
}
private void Cancel_Click(object sender, EventArgs e) 
{
   if (_doc.BusyState != BusyStateEnum.Ready) 
       _doc.Cancel = true;
   else 
       Console.WriteLine("Document is not generating, nothing to cancel");
}</code></pre>

</div>
