473,401 Members | 2,068 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,401 software developers and data experts.

One last (I promise) Threading dilemma

I have a form 2 which contains a datagrid. In form 1 I have a procedure -
"PopulateC" which populates it with values. The instance of form 2 is
"Matrix_C" and it is global.
I determine the data for the grid with:

Dim flag As Boolean = False

Private Sub start_thread(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim thread1 As New System.Threading.Thread(AddressOf bd)
thread1.Start()
End Sub

Private Sub Abort_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
flag = True
End Sub

Public Sub bd()
Some things
Dim i, j, k As Integer
For i = 1 To 1000000
For j = 1 To 1000
If flag = True Then GoTo 1
Next
Next
Some more things
1: flag = False
populateC()
End Sub

When I run the program and click button 1 (and do not abort) I get:
Controls created on one thread cannot be parented to a control on a
different thread. (The debugger points to my populateC procedure)

I understand the error but I am hoping there is a work around (something
like a thread done event) that will enable seamless population of the grid.
--
mark b
Dec 6 '05 #1
1 815
"mark" <ma**@discussions.microsoft.com> schrieb
When I run the program and click button 1 (and do not abort) I get:
Controls created on one thread cannot be parented to a control on a
different thread. (The debugger points to my populateC procedure)

I understand the error but I am hoping there is a work around
(something like a thread done event) that will enable seamless
population of the grid. --


Use grid.Invoke/grid.BeginInvoke to call a sub in the right thread that
fills the grid.
Armin

Dec 6 '05 #2

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

Similar topics

2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
2
by: rb531 | last post by:
Guys, I am struck up with a dilemma whether to use threading or delgates for asynchronous processing. Can anyone throw some light on this? Please let me know which one is better. Thanks
16
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
4
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
10
by: Janto Dreijer | last post by:
I have been having problems with the Python 2.4 and 2.5 interpreters on both Linux and Windows crashing on me. Unfortunately it's rather complex code and difficult to pin down the source. So...
0
by: bakermi | last post by:
Hello, I have coded an IRC bot in Python. Each inbound packet is parsed, and once the bot decides whether it is a command directed at the bot or not, it will either discard the packet or make a...
2
by: John Rogers | last post by:
I have some code that does a recursive copy of whatever folder I give to it to copy the structure where I want it. I have it running in a single thread to make it a bit more efficient. So far it...
126
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
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
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
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,...
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.