473,386 Members | 1,720 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,386 software developers and data experts.

cross Thread not valid

Hi Guys,

I have a question on the Vb.net code I am working on. I have a winform
that has a button that starts a thread, I would like to close the
winform when thread finishes or crashes. Is there a way to call
winform.close from the thread?

Thank you

Alan

Sep 25 '06 #1
2 967
<el*****@hotmail.comschrieb:
I have a question on the Vb.net code I am working on. I have a winform
that has a button that starts a thread, I would like to close the
winform when thread finishes or crashes. Is there a way to call
winform.close from the thread?
Yes, you can call it by calling the form's 'Invoke' or 'BeginInvoke' method.

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

Sep 25 '06 #2
Thanks a lot for helping. My code looks like the following:
private sub run()
try
calculate()
winform.close
catch ex
winform.close
end try
end function

public sub button1_onclick()
dim a as thread (addressof run)
a.start
end sub

Can you help point out where I should use invoke and beginInvoke?

Thank you!
Herfried K. Wagner [MVP] wrote:
<el*****@hotmail.comschrieb:
I have a question on the Vb.net code I am working on. I have a winform
that has a button that starts a thread, I would like to close the
winform when thread finishes or crashes. Is there a way to call
winform.close from the thread?

Yes, you can call it by calling the form's 'Invoke' or 'BeginInvoke' method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Sep 26 '06 #3

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

Similar topics

23
by: Jeff Rodriguez | last post by:
Here's what I want do: Have a main daemon which starts up several threads in a Boss-Queue structure. From those threads, I want them all to sit and watch a queue. Once an entry goes into the...
2
by: Mikael Syska | last post by:
Hey, Cross-thread operation not valid: Control 'ThreadStartedAt' accessed from a thread other than the thread it was created on I get this Exception when I try to update some labels/textbox's...
1
by: Mesan | last post by:
I'm getting a "Cross-thread operation not valid" Exception and I can't figure out why. I've got a BackgroundWorker that creates a UserControl with a whole lot of other user controls inside of...
8
by: Pieter | last post by:
Hi, I'm having some weird problem using the BackGroundWorker in an Outlook (2003) Add-In, with VB.NET 2005: I'm using the BackGroundWorker to get the info of some mailitems, and after each item...
11
by: HairlipDog58 | last post by:
Hello, There are several 'cross-thread operation not valid' exception postings in the MSDN discussion groups, but none address my exact situation. I have authored a .NET component in Visual C#...
3
by: Pieter Coucke | last post by:
Hi, In my VB.NET 2005 application I'm generating and sending emails using the outlook-object model (2003). When a mail is Send (MailObject_Send), I raise an event in a global class, that is...
3
by: Le Minh | last post by:
I receive this message: "System.InvalidOperationException: Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on" .... this is a exception....
5
by: nospam | last post by:
Hi all. I have encountered a "Cross-thread operation not valid" error in a test program I created and although I have came up with a solution I don't like the performance of the program. I...
1
Raventara
by: Raventara | last post by:
Hi peoples.... This is a pain in the ass: Cross-thread operation not valid: Control 'TextBox1' accessed from a thread other than the thread it was created on. I am trying to update the text in...
3
by: kimiraikkonen | last post by:
Hi, I was looking for an example on CodeProject and saw an interesting thing, i downloaded the article source code and converted to my VB 2005 Express and compiled with no problem, however when i...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.