.net - Creating a thread using an Anonymous method - how to solve issue with Closure? -


Suppose you have the following:

  as integer for i = 0 From 10th to 10th in the form of a new thread (sub () (all () console as the integer = 0 to 10 dim t. ("hello:" & amp; amp;; & amp; amp;; & amp; Sub) T. Start (Next)   

I know that this is a closing problem, but what is the correct way to write an anonymous method for this matter ... I call it 1 for "1" I want to print all the numbers 10 and 1 to 10. For "J"

You just need to get a local copy of i And j inside > loop:

  as integer = 0 to 10 for integer as j = 0 to 10 Dim iCopy = I dim slowed as jCopy = Jammu Tim New Thread (sub () (console). ("Hello:" and Icopy and JCP) end sub) T. Next >>   

Next you will find a new iCopy and jCopy variable on each invoice of the loop.

This advice only deals with the following results from the warning you receive from your original code:

  Warning BC42324: Using the recurrence variable in lambda expression can be an unexpected result Instead, create a local variable within the loop and assign it to the value of the frequency variable.    

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

php - how to change mysql_result($res, 0, "url"); to mysqli -

Matlab transpose a table vector -