473,414 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Run a sub from within a tread?

I'm a newbie to threads. I can run
"comboProfiles_SelectedIndexChanged(sender, e)" from any normal sub in my
project however if I run this from within a new thread I've started it
doesn't like "sender" or "e". I know sending info from within a thread is
different but what I'm doing should be simple so if someone can help me out
I sure would appreciate it.

Thanks Much,
Justin
Nov 21 '05 #1
2 1064
"Justin" <Ju****@NoSpam.com> schrieb:
I'm a newbie to threads. I can run
"comboProfiles_SelectedIndexChanged(sender, e)" from any normal sub in my
project however if I run this from within a new thread I've started it
doesn't like "sender" or "e". I know sending info from within a thread is
different but what I'm doing should be simple so if someone can help me
out


First, I would rethink if calling an event handler is really the best
solution.

Second, don't forget that Windows Forms controls' instance members are not
safe for multithreading.

Third, you can use
'Control.Invoke'/'Control.BeginInvoke'/'Control.InvokeRequired' to call a
method in the context of the main UI thread from within a secondary thread:

Multithreading in Windows Forms-Anwendungen
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithreading&lang=de>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Awesome. Thanks Herfried.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"Justin" <Ju****@NoSpam.com> schrieb:
I'm a newbie to threads. I can run
"comboProfiles_SelectedIndexChanged(sender, e)" from any normal sub in my
project however if I run this from within a new thread I've started it
doesn't like "sender" or "e". I know sending info from within a thread
is different but what I'm doing should be simple so if someone can help
me out


First, I would rethink if calling an event handler is really the best
solution.

Second, don't forget that Windows Forms controls' instance members are not
safe for multithreading.

Third, you can use
'Control.Invoke'/'Control.BeginInvoke'/'Control.InvokeRequired' to call a
method in the context of the main UI thread from within a secondary
thread:

Multithreading in Windows Forms-Anwendungen
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithreading&lang=de>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: David Hayes | last post by:
I tried finding an answer on http://www.quirksmode.org/ without success. I am attempting a complicated Frames structure. I have made it work in IE, but not Netscape. I begin with three...
2
by: Craig | last post by:
I'm trying to do this within a control I've created: Cursor.Current = Cursors.WaitCursor; During the initialization of the parent form, my control gets added to the form, and while the control...
2
by: Jon | last post by:
All, I'm currently working with a PHP-based CMS application, and am begining to put the finishing touches on it via Javascript validation. Currently, I'm using fairly standard methods of...
9
by: 47computers | last post by:
Pretty new to PHP, I recently started learning about error trapping. As of right now, I include the following into a page in my website: -------BEGIN PASTE-------- error_reporting(E_ERROR |...
3
by: matko | last post by:
This is a long one, so I'll summarize: 1. What are your opinions on raising an exception within the constructor of a (custom) exception? 2. How do -you- validate arguments in your own...
5
by: =?Utf-8?B?VmFubmk=?= | last post by:
Hi, I have a component where I need to have thread-safe access to a list. Operations on the list are done in critical sections (lock (lockObject) { ... } ) in the usual way, to make sure that no...
4
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
5
by: herenbdy | last post by:
I've been working on a Java based game in order to learn Java, but the game is functional only within my IDE (Eclipse). This image shows the file structure of my project:...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.