Simply add two buttons and two ListBoxes to your form then add this code Code (vb.net): <div class="vbnet" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #008080; font-style: italic;">'Thread vs Non Threaded example coded by Robawtic</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #008080; font-style: italic;">'vb.Net 2005</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #008080; font-style: italic;">'Thursday, April 07, 2007</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #008080; font-style: italic;">'Published to [url=http://www.digibliss.net]http://www.digibliss.net[/url], [url=http://www.neofriends.net]http://www.neofriends.net[/url]</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #008080; font-style: italic;">'Any questions feel free to contact me @ [email=robawtic@gmail.com]robawtic@gmail.com[/email],</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #008080; font-style: italic;">'MSN: [email=robawtic@gmail.com]robawtic@gmail.com[/email]</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #008080; font-style: italic;">'YIM: robawtic</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">ComponentModel</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Threading</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Forms</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Class</span> Form1</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'Declaring our threads</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> LoginThread1 <span style="color: #FF8000;">As</span> Thread</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> LoginThread2 <span style="color: #FF8000;">As</span> Thread</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'A delegate is similar to a pointer, it allows you to do many things one of which is </span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'to work with cross threading.</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'These next two Delegate Sub's are just defining our delegates</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Delegate</span> <span style="color: #0600FF;">Sub</span> EnableUIDelegate<span style="color: #000000;">(</span><span style="color: #FF8000;">ByVal</span> Value <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Delegate</span> <span style="color: #0600FF;">Sub</span> SetTextDelegate<span style="color: #000000;">(</span><span style="color: #FF8000;">ByVal</span> MyControl <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Forms</span>.<span style="color: #0000FF;">ListBox</span>, <span style="color: #FF8000;">ByVal</span> Message <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> Button1_Click<span style="color: #000000;">(</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> System.<span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">)</span> <span style="color: #FF8000;">Handles</span> Button1.<span style="color: #0000FF;">Click</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'Unthreaded long loop no explaining need I hope.</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> ListBox1.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Clear</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> ListBox2.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Clear</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">Dim</span> Counter <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> = <span style="color: #FF0000;">0</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">For</span> Counter = <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">To</span> <span style="color: #FF0000;">500</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> ListBox1.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">(</span>Counter<span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> Thread.<span style="color: #0000FF;">Sleep</span><span style="color: #000000;">(</span><span style="color: #FF0000;">100</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Next</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">For</span> Counter = <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">To</span> <span style="color: #FF0000;">500</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> ListBox2.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">(</span>Counter<span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> Thread.<span style="color: #0000FF;">Sleep</span><span style="color: #000000;">(</span><span style="color: #FF0000;">100</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Next</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> Button2_Click<span style="color: #000000;">(</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> System.<span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">)</span> <span style="color: #FF8000;">Handles</span> Button2.<span style="color: #0000FF;">Click</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'This is our threaded version of adding items to a list box</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> ListBox1.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Clear</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> ListBox2.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Clear</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'EnableUI(bool) just disables our controls per defined in the sub.</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> EnableUI<span style="color: #000000;">(</span><span style="color: #0600FF;">False</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'Create our first thread</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">LoginThread1</span> = <span style="color: #FF8000;">New</span> System.<span style="color: #0000FF;">Threading</span>.<span style="color: #0000FF;">Thread</span><span style="color: #000000;">(</span><span style="color: #804040;">AddressOf</span> advantage1<span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'Tell the program to run it as a background thread</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">LoginThread1</span>.<span style="color: #0000FF;">IsBackground</span> = <span style="color: #0600FF;">True</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'Create our second thread</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">LoginThread2</span> = <span style="color: #FF8000;">New</span> System.<span style="color: #0000FF;">Threading</span>.<span style="color: #0000FF;">Thread</span><span style="color: #000000;">(</span><span style="color: #804040;">AddressOf</span> advantage2<span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'Tell the program to run it as a background thread</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">LoginThread2</span>.<span style="color: #0000FF;">IsBackground</span> = <span style="color: #0600FF;">True</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'Start the threads</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">LoginThread1</span>.<span style="color: #0000FF;">Start</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span> : <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">LoginThread2</span>.<span style="color: #0000FF;">Start</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'Enable the controls again</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">EnableUI</span><span style="color: #000000;">(</span><span style="color: #0600FF;">True</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> advantage1<span style="color: #000000;">(</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'The same loop used in The Button1_Click Event, just threaded!</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">Dim</span> Counter <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> = <span style="color: #FF0000;">0</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">For</span> Counter = <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">To</span> <span style="color: #FF0000;">500</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> SetText<span style="color: #000000;">(</span>ListBox1, Counter<span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> Thread.<span style="color: #0000FF;">Sleep</span><span style="color: #000000;">(</span><span style="color: #FF0000;">100</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Next</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> advantage2<span style="color: #000000;">(</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'The same loop used in The Button1_Click Event, just threaded!</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">Dim</span> Counter <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> = <span style="color: #FF0000;">0</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">For</span> Counter = <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">To</span> <span style="color: #FF0000;">500</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> SetText<span style="color: #000000;">(</span>ListBox2, Counter<span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> Thread.<span style="color: #0000FF;">Sleep</span><span style="color: #000000;">(</span><span style="color: #FF0000;">100</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Next</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> EnableUI<span style="color: #000000;">(</span><span style="color: #FF8000;">ByVal</span> Value <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'This IF Else Then is used to test if our objects need to be invoked</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'for cross threading.</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">If</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">InvokeRequired</span> <span style="color: #FF8000;">Then</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">Dim</span> args <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span> = <span style="color: #000000;">{</span>Value<span style="color: #000000;">}</span> <span style="color: #008080; font-style: italic;">'the arguments for the sub</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">(</span><span style="color: #FF8000;">New</span> EnableUIDelegate<span style="color: #000000;">(</span><span style="color: #804040;">AddressOf</span> EnableUI<span style="color: #000000;">)</span>, args<span style="color: #000000;">)</span> <span style="color: #008080; font-style: italic;">'Invoke our controls</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Else</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'if no invoke is neccessary then just send to them normally</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Button1</span>.<span style="color: #0000FF;">Enabled</span> = Value</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Button2</span>.<span style="color: #0000FF;">Enabled</span> = Value</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> SetText<span style="color: #000000;">(</span><span style="color: #FF8000;">ByVal</span> MyControl <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Forms</span>.<span style="color: #0000FF;">ListBox</span>, <span style="color: #FF8000;">ByVal</span> Message <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'This IF Else Then is used to test if our objects need to be invoked</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'for cross threading.</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">If</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">InvokeRequired</span> <span style="color: #FF8000;">Then</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">Dim</span> args <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span> = <span style="color: #000000;">{</span>MyControl, Message<span style="color: #000000;">}</span> <span style="color: #008080; font-style: italic;">'the arguments for the sub</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">(</span><span style="color: #FF8000;">New</span> SetTextDelegate<span style="color: #000000;">(</span><span style="color: #804040;">AddressOf</span> SetText<span style="color: #000000;">)</span>, args<span style="color: #000000;">)</span> <span style="color: #008080; font-style: italic;">'Invoke our controls</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Else</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'if no invoke is neccessary then just send to them normally</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> MyControl.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">(</span>Message<span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> Pause<span style="color: #000000;">(</span><span style="color: #FF8000;">ByVal</span> Delay <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Double</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #008080; font-style: italic;">'A simple pause function</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">Dim</span> DT1 <span style="color: #FF8000;">As</span> DateTime = DateTime.<span style="color: #0600FF;">Now</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">Dim</span> DT2 <span style="color: #FF8000;">As</span> DateTime = DateTime.<span style="color: #0600FF;">Now</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">Dim</span> TS <span style="color: #FF8000;">As</span> TimeSpan = DT2 - DT1</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">While</span> Convert.<span style="color: #0000FF;">ToDouble</span><span style="color: #000000;">(</span>TS.<span style="color: #0000FF;">TotalMilliseconds</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">)</span> < Delay</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> DT2 = DateTime.<span style="color: #0600FF;">Now</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> TS = DT2 - DT1</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> Application.<span style="color: #0600FF;">DoEvents</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">While</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li></ol></div>
what the hell!!!!!!!!!!!!!! the first one just scrolled down the first listbox (like it was pressing enter) the second one added consecutive number into both listboxes is it meant to do that? if so how is that threading and not threading?
Some things to notice, after clicking the first button, 1. try dragging the form around, notice how the program goes white (The gui stops being updated!!!!) 2. notice how the first listbox is counted 0 to 500, then the second listbox is counted 0 to 500 --------- now click the 2nd button (after the first has finished) 1. try dragging the form around, notice how the program does no go white (The gui is being updated!!!!) 2. notice how both listbox's are filled up at the same time.
What I was wondering is what exactly threading could be used for in neopets based programming. All i could think of is that different processes could be done at different times but you wouldn't exactly be able to have different threads going to different pages unless you have proxies running. I mean if you needed to grab a large amount of things you could use threads to do it quicker but actually visiting the pages this wouldn't be helpful for... I mean in the end i don't know how much of a speed gain there would be from using threads vs. not using threading just to gatter data. I know abers and such are all based on speed but how much faster can you make a program? Will the extra 10 ms really make a difference? I'm not totally sure if it would be but hey i could be totally wrong on this. Honestly i am still really new to the idea of using threads. btw, i am not talking about using threads like this for different accounts, only different processes.
what threading really does is making the gui consistantly update expon's porgram's appear to freeze as they are non-threaded so when it is doing something it cannot also update the gui
That's why it is a good idea to thread tasks for reasons such as: The GUI not freezing. Can run different tasks at same time. GUI gets updated. Can stop the program when threaded as the GUI updates all the time.