473,507 Members | 9,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

adding controls from a different thread

Hi folks,

I have a form in which I'm starting a separate thread (which is searching
directories for image-files and generating thumbnails of them in different
dir). Within the form, I also have a FileSystemWatcher, which will trigger
as soon as a thumbnail is generated from that thread. When triggered, the
thumbnail-image that has just been found is to be displayed in a
"Panel-UserControl" (consisting of a panel and a couple of other controls).
The Panel-UserControl itself will add one Item-UserControl (consisting of a
picturebox and a couple of other controls) for each thumbnail to be
displayed - and that's where everything goes boom:
The FSW's creation-trigger (have tried the trigger-function residing both
in the form and the Panel-UserControl) will call the Panel-UserControl's
AddThumbnail-function which in turn will create a new Item-UserControl in
which that image is to be displayed. But as soon as I'm issuing a
"Panel.Controls.Add ItemControl" or a "ItemControl.Parent=PanelControl",
I'll get the exception ~"controls created on one thread cannot be parented
to another thread".

If it's just not possible (at least I didn't find any hints searching the
web) how would I start a scenario where:
- the main thread includes a thumbnail-listbox (i.e. a user-control that
shows the thumbnails)
- a separate thread creates thumbnails from files within a set of
directories
- after a thumbnail-file has been created, it is to be added to the
thumbnail-listbox

I've been trying this for over a week now so any help will be greatly
appreciated ...

TIA & Cheers,
Olaf
Nov 21 '05 #1
2 2025
Hi,

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

Ken
---------------------
"Olaf Rabbachin" <Ol*********@IntuiDev.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi folks,

I have a form in which I'm starting a separate thread (which is searching
directories for image-files and generating thumbnails of them in different
dir). Within the form, I also have a FileSystemWatcher, which will trigger
as soon as a thumbnail is generated from that thread. When triggered, the
thumbnail-image that has just been found is to be displayed in a
"Panel-UserControl" (consisting of a panel and a couple of other controls).
The Panel-UserControl itself will add one Item-UserControl (consisting of a
picturebox and a couple of other controls) for each thumbnail to be
displayed - and that's where everything goes boom:
The FSW's creation-trigger (have tried the trigger-function residing both
in the form and the Panel-UserControl) will call the Panel-UserControl's
AddThumbnail-function which in turn will create a new Item-UserControl in
which that image is to be displayed. But as soon as I'm issuing a
"Panel.Controls.Add ItemControl" or a "ItemControl.Parent=PanelControl",
I'll get the exception ~"controls created on one thread cannot be parented
to another thread".

If it's just not possible (at least I didn't find any hints searching the
web) how would I start a scenario where:
- the main thread includes a thumbnail-listbox (i.e. a user-control that
shows the thumbnails)
- a separate thread creates thumbnails from files within a set of
directories
- after a thumbnail-file has been created, it is to be added to the
thumbnail-listbox

I've been trying this for over a week now so any help will be greatly
appreciated ...

TIA & Cheers,
Olaf
Nov 21 '05 #2
Hi,

Ken Tucker [MVP] wrote:
http://msdn.microsoft.com/msdnmag/is...s/default.aspx


thanks, Ken.

Cheers,
Olaf
Nov 21 '05 #3

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

Similar topics

5
5257
by: Sue | last post by:
On code-behind page: (attributes set programatically for each of these elements) linkbutton added to tablecell textbox added to tablecell tablecells added to tablerow tablerow added to table...
10
4844
by: David | last post by:
Can anyone give me a quick code snippet (that is standards-based) for adding OPTION tags to a SELECT dynamically. I have no problem doing it in IE but I am kind of new to the whole standards world...
2
3705
by: avivgur | last post by:
Hello, I am writing a program in Visual C# and I have encountered a problem. In my program I want to dynamically create a multitude of controls (thousands) on a form. The problem is that calling...
1
14224
by: VMI | last post by:
Im using a separate thread in my code to copy a huge file, but I get the "Controls created on one thread cannot be parented to a control on a different thread" when I want to update the Form...
3
4856
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
3
2327
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
3
4166
by: Arthur Dzhelali | last post by:
I am trying dynamically create controls and add them to the form on the Separate thread. I know that I have to use delegate in order to update preexisting controls on the form, but when I ma...
4
3556
by: Charles Law | last post by:
Hi guys. I have two threads: a main thread and a background thread. Lots of stuff happens in the background thread that means I have to update several (lots) of controls on a form. It is...
3
2062
by: Toe Dipper | last post by:
In short we have a lengthy process when a form is loaded that adds activex controls to our windows form. This process in itself works fine however we would like to push this processing to a thread...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
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
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5041
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...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.