473,666 Members | 2,337 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 FileSystemWatch er, 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.Pa rent=PanelContr ol",
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 2032
Hi,

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

Ken
---------------------
"Olaf Rabbachin" <Ol*********@In tuiDev.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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 FileSystemWatch er, 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.Pa rent=PanelContr ol",
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
5277
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 (table.ID is TestTable) On .aspx page: <HeaderTemplate> <asp:Table ID="TestTable" runat="Server" /> </HeaderTemplate>
10
4868
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 and can't figure out how to make it work in, for instance, Firefox. Right now the code I am using is as follows: newOpt=document.createElement('OPTION'); newOpt.id='optKeyword'; newOpt.label='Keyword';...
2
3721
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 the Controls.Add() method several times or even calling the Controls.AddRange() method once can take a huge amount of time. Therefore, I would like to be able to run the loop that creates the controls on a different thread and meanwhile give the user...
1
14254
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 controls after makeBackup is complete. I know what the problem is (I'm trying to update controls from a thread that did not create them), but how can I fix it? This my code: private delegate void BackupCompletedEventHandler(); private event...
3
4872
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 the best method? Do you have a sample of how to do this?
3
2339
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 page. So whenever the Admin person comes to know about the new category in the market he will be adding as different Sub-Categories for example ABAP, BDC etc..etc.. on every click event as Checkboxes. And these controls(checkboxes) should remain...
3
4177
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 trying create new control I am getting this message: System.ArgumentException: Controls created on one thread cannot be parented to a control on a different thread.
4
3569
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 quite tiresome to have to write code to call MyControl.Invoke for each control on the form, along with the delegates that are required for each. Is there a better way to do this? What I mean is, if I could marshal the
3
2087
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 but are stumped so far. Our goal is simply to allow the form to fully display while the controls are being added. Preferrably with a progressbar to let them know that the form is still being built. Here are some snippets.
0
8440
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8863
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7378
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6189
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5661
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.