Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 198

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Batch Messaging Example</title>
    <link rel="stylesheet" type="text/css" href="../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Batch Messaging Example</h1><script>
//We attach this function to a browser object as a variable so that if multiple of these blocks are
//present on the same page, then they will simply over-write eachother with the same function instead
//of generating a naming collision.
window.WikiCodeFormattingCopyToClipboard = function copyToClipboard(sID){
	var sContent = document.getElementById(sID).innerText;
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", sContent);
	}
	else
	{
		alert("You must enable javascript access to your clipboard for this feature to work. Please referr to your browser documentation or Google search for instructions.");
	}
}
</script><p>Let's create a small example to test batch messaging mode
behavior. We will use bulk insert with and without batch messaging
configuration.</p>


<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">BatchExample.cs: <span class="fscMemberName">FillUpDb</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> FillUpDb(IConfiguration configuration)
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_67_809_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectContainer container </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenClient(configuration, Host, Port, User,
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                        Password);
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">try</span><span style="color: #000000;">
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_229_716_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Testing inserts</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                DateTime dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">for</span><span style="color: #000000;"> (</span><span style="color: #0000FF;">int</span><span style="color: #000000;"> i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">; i </span><span style="color: #000000;">&lt;</span><span style="color: #000000;"> NoOfObjects; i</span><span style="color: #000000;">++</span><span style="color: #000000;">)
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Open_Text').style.display='inline';"/>                </span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_403_527_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    Pilot pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">pilot #</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> i, i);
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    container.Set(pilot);
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>                }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                DateTime dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                TimeSpan diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1;
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Operation time: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.Milliseconds </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms.</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>            }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">finally</span><span style="color: #000000;">
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_FillUpDb_203_50_749_799_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                container.Close();
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>            }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div>

</span>
<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">BatchExample.vb: <span class="fscMemberName">FillUpDb</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub FillUpDb()</span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_FillUpDb_315_50_15_898_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> FillUpDb(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration)
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> container </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenClient(configuration, Host, Port, User, Password)
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Testing inserts</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> i </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">While</span><span style="color: #000000;"> i </span><span style="color: #000000;">&lt;</span><span style="color: #000000;"> NoOfObjects
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">pilot #</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> i.ToString(), i)
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    container.Set(pilot)
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    System.Math.Min(System.Threading.Interlocked.Increment(i), i </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;">)
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">While</span><span style="color: #000000;">
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> diff </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> TimeSpan </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Operation time: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.Milliseconds.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms.</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                container.Close()
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>Let's configure the server and run the insert operation
first without batch messages, then with batch messages:</p>



<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">BatchExample.cs: <span class="fscMemberName">Main</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> Main(</span><span style="color: #0000FF;">string</span><span style="color: #000000;">[] Args)
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_47_552_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectServer db4oServer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenServer(Db4oFileName, Port);
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_160_458_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db4oServer.GrantAccess(User, Password);
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                IConfiguration configuration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration();
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                FillUpDb(configuration);
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                configuration.ClientServer().BatchMessages(</span><span style="color: #0000FF;">true</span><span style="color: #000000;">);
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                FillUpDb(configuration);
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>            }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">finally</span><span style="color: #000000;">
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchCS.ZipsBatchExample.Cs_BatchExample.Cs_Main_556_46_491_542_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db4oServer.Close();
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>            }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">


<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">BatchExample.vb: <span class="fscMemberName">Main</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub Main()</span><span id="ResourcesReferenceClient-ServerBatch_ModeBatchVB.ZipsBatchExample.Vb_BatchExample.Vb_Main_668_46_14_517_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> Main(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> Args </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">String</span><span style="color: #000000;">())
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db4oServer </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectServer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenServer(File, Port)
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db4oServer.GrantAccess(User, Password)
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration()
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                FillUpDb(configuration)
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                configuration.ClientServer.BatchMessages(</span><span style="color: #0000FF;">True</span><span style="color: #000000;">)
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                FillUpDb(configuration)
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db4oServer.Close()
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>


</span>


<p>You can try different values of <code>NO_OF_OBJECTS</code>
constant to see the difference. </p>

<p>If the value of <code>NO_OF_OBJECTS</code> is high
(&gt;1,000,000) you may notice that the memory consumption increases a lot. In
order to decrease it, try using:</p>



<span name="cs_wiki_filter" csw_filters="cs"><p>c#:&nbsp;</p>

<p><code>container.Ext().Configure().ClientServer().MaxBatchQueueSize(size);</code></p>

</span>

<span name="cs_wiki_filter" csw_filters="vb"><p>VB:&nbsp;</p>

<p><code>container.Ext().Configure().ClientServer().MaxBatchQueueSize(size);</code></p>

</span>

<p>Specify the size parameter according to the desirable memory
consumption limit.</p></div>
    </div>
    <div id="footer">
					This revision (3) was last Modified 2007-03-13T19:41:00 by Tetyana.
				</div>
  </body>
</html>