Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your options are:</p> <ul> <li>Encapsulate the parameters in a new class, and put the method to use for the delegate into that class.</li> <li>Use anonymous functions (anonymous methods or lambda expressions) to do the same thing automatically with captured variables.</li> </ul> <p>The latter is generally easier of course. You haven't shown what you're doing with the thread, but you might do something like:</p> <pre><code>string storeID = "..."; string queryObject = "..."; Thread t = new Thread(() =&gt; StartDNIThread(storeID, queryObject)); t.Start(); </code></pre> <p>Note that because the <em>variables</em> are captured, you shouldn't change the values until after you know the thread has actually started. You can work around this by using captured variables only used by the anonymous function:</p> <pre><code>string storeID = "..."; string queryObject = "..."; string storeIDCopy = storeID; string queryObjectCopy = queryObject; Thread t = new Thread(() =&gt; StartDNIThread(storeIDCopy, queryObjectCopy)); t.Start(); // You can now change storeID and queryObject freely </code></pre> <p>This is particularly important if you're doing anything in a loop, as the loop variables themselves will change. For example:</p> <pre><code>foreach (string storeID in stores) { string storeIDCopy = storeID; Thread t = new Thread(() =&gt; StartDNIThread(storeIDCopy, queryObject)); t.Start(); } </code></pre> <p>If you're using the thread pool or any other way of starting threads, the pattern is basically the same.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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