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

Cross-thread error in debug mode, works fine outside VS

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 debug the
program to and split a file(size doesn't matter) in debug mode with
VS, that is, a file merge-split tool, nearly i always get a "cross-
thread operation not valid" error for progress bar, whereas double
clicking and launching program without Visual Studio causes no problem
and runs just fine.

Here is article:
http://www.codeproject.com/KB/files/...erge_tool.aspx

Here is source code:
http://www.codeproject.com/KB/files/...SplitMerge.zip

I read similar issues on the net about VS but none of them were
helpful,

Is there any bug in VS or is it a known indication? Because if it was
caused by Visual Studio, it's insane that every developer can be
forced to think that the error is being caused by a coding mistake, in
fact there's no problem if you don't debug it via VS.

Thanks,

Onur Güzel
Aug 19 '08 #1
3 3717
Hi Onur,

If you are getting a cross thread exception, it means the UI control is
being updated from a non UI thread, in which case you should use
Control.Invoke
"kimiraikkonen" <ki*************@gmail.comwrote in message
news:5a**********************************@8g2000hs e.googlegroups.com...
>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 debug the
program to and split a file(size doesn't matter) in debug mode with
VS, that is, a file merge-split tool, nearly i always get a "cross-
thread operation not valid" error for progress bar, whereas double
clicking and launching program without Visual Studio causes no problem
and runs just fine.

Here is article:
http://www.codeproject.com/KB/files/...erge_tool.aspx

Here is source code:
http://www.codeproject.com/KB/files/...SplitMerge.zip

I read similar issues on the net about VS but none of them were
helpful,

Is there any bug in VS or is it a known indication? Because if it was
caused by Visual Studio, it's insane that every developer can be
forced to think that the error is being caused by a coding mistake, in
fact there's no problem if you don't debug it via VS.

Thanks,

Onur Güzel
Aug 20 '08 #2
On Aug 20, 4:30 am, "Bill McCarthy" <B...@localhost.comwrote:
Hi Onur,

If you are getting a cross thread exception, it means the UI control is
being updated from a non UI thread, in which case you should use
Control.Invoke

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:5a**********************************@8g2000hs e.googlegroups.com...
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 debug the
program to and split a file(size doesn't matter) in debug mode with
VS, that is, a file merge-split tool, nearly i always get a "cross-
thread operation not valid" error for progress bar, whereas double
clicking and launching program without Visual Studio causes no problem
and runs just fine.
Here is article:
http://www.codeproject.com/KB/files/...erge_tool.aspx
Here is source code:
http://www.codeproject.com/KB/files/...Tool/FileSplit...
I read similar issues on the net about VS but none of them were
helpful,
Is there any bug in VS or is it a known indication? Because if it was
caused by Visual Studio, it's insane that every developer can be
forced to think that the error is being caused by a coding mistake, in
fact there's no problem if you don't debug it via VS.
Thanks,
Onur Güzel
But it runs fine if i don't debug the project under VS 2005. I
recommend downloading and running the article source code given
previously to experience what i mean. Running program alone from "bin"
folder causes NO cross-thread error, but in debug mode i get cross-
thread error and that was the point i was wondering if it's Visual
Stutio's problem.

It's weird and important for VS.

Thanks,

Onur Güzel
Aug 20 '08 #3
Hi Onur,

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:93**********************************@2g2000hs n.googlegroups.com...
>
But it runs fine if i don't debug the project under VS 2005. I
recommend downloading and running the article source code given
previously to experience what i mean. Running program alone from "bin"
folder causes NO cross-thread error, but in debug mode i get cross-
thread error and that was the point i was wondering if it's Visual
Stutio's problem.

It's weird and important for VS.

Right it *may* run fine , but it also may not. You should never update the
UI fro ma non UI thread, instead you should use Invoke. So the code in
windows.forms looks to see if a debugger is attached, and if so it throws an
InvalidOperationException. This is to make debugging safer, and help you
track down otherwise difficult to simulate runtimes errors that can occur.
When you get this exception you should modify the code to use Control.Invoke
to bring the code back to the UI thread before setting the properties of any
controls.

Aug 21 '08 #4

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

Similar topics

7
by: Web Master | last post by:
Are there any good websites or books that deal with cross platform XML? I'd like to target Internet Explorer/Netscape Navigator 5 or later, as well as Opera, possibly konqueror on Linux as well. ...
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
0
by: demibee | last post by:
Thought this might be of interest to some out there... For those who've never encountered it, it's a free, open-source, cross-platform GUI library (Windows/Mac/Linux). Forte's Agent 2.0 will be...
4
by: David Peach | last post by:
Hello, hope somebody here can help me... I have a query that lists defects recorded in a user defined date range. That query is then used as the source for a Cross Tab query that cross-tabs count...
7
by: Scott M. | last post by:
How can I disable the cross-site scripting check for one particular page of a site?
1
by: Rob Woodworth | last post by:
Hi, I'm having serious problems getting my report to work. I need to generate a timesheet report which will contain info for one employee between certain dates (one week's worth of dates). I...
6
by: Robert Bravery | last post by:
Hi all, Can some one show me how to achieve a cross product of arrays. So that if I had two arrays (could be any number) with three elements in each (once again could be any number) I would get:...
1
by: Otacon22 | last post by:
Hi all, I want to create a robot with a router board based on processor atheros 2.6, called "fonera". I have installed a version of linux, Openwrt and python and i want to use it for some...
6
by: Bart Van der Donck | last post by:
Hello, I'm presenting my new library 'AJAX Cross Domain' - a javascript extension that allows to perform cross-domain AJAX requests. http://www.ajax-cross-domain.com/ Any comments or...
3
by: Squat'n Dive | last post by:
Does anyone have an idea why -fno-strict-aliasing is turned off when cross compiling? in configure generated for 2.4.4: case $GCC in yes) # Python violates C99 rules, by casting between...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.