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

Using RichTextBox in a thread?

Hi,

If I inside a thread creates a RichTextBox and only use this inside the
thread, will there be any thread problems?

I need to convert between Text and RTF inside a thread.

Thanks!!

M O J O

Nov 20 '05 #1
12 2139
* M O J O <mojo@_no_spam_delete_this_newwebsolutions.dk> scripsit:
If I inside a thread creates a RichTextBox and only use this inside
the thread, will there be any thread problems?

I need to convert between Text and RTF inside a thread.


I don't think so.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Hi,

Yes, very probably it will be a problem.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote in message
news:eE*************@tk2msftngp13.phx.gbl...
Hi,

If I inside a thread creates a RichTextBox and only use this inside the
thread, will there be any thread problems?

I need to convert between Text and RTF inside a thread.

Thanks!!

M O J O

Nov 20 '05 #3
"Miha Markic" <miha at rthand com> schrieb
Hi,

Yes, very probably it will be a problem.


Why?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
Hi,

Because UI control shouldn't be touched from within non-UI thread.
I am not 100% sure in your case though.
Let us know if you manage to use it.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
"Miha Markic" <miha at rthand com> schrieb
Hi,

Yes, very probably it will be a problem.


Why?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
"Miha Markic" <miha at rthand com> schrieb
Because UI control shouldn't be touched from within non-UI thread.
If you crete a control, it is not a non-UI thread anymore. See the 2nd
paragarph after the headline "Queued Messages" in the following topic:
http://msdn.microsoft.com/library/en...sagequeues.asp
I am not 100% sure in your case though.
Let us know if you manage to use it.


I think/hope MOJO will tell us. :-)
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6
Hi Mojo,

Thanks for posting in the community. My name is Peter, and I will be
assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to use the RichTextBox
in a non-UI thread.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I am researching the issue, if I have any new information, I will update
with you ASAP.

Have a nice day!
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #7
Thank you all for your input.

I'm still not sure that using a RichTextBox created in a thread is un/safe.

Maybe Microsoft can give me some feedback here (Ray?)???

Thanks again!!!

M O J O

M O J O wrote:
Hi,

If I inside a thread creates a RichTextBox and only use this inside the
thread, will there be any thread problems?

I need to convert between Text and RTF inside a thread.

Thanks!!

M O J O


Nov 20 '05 #8
Hi Mojo,

Based on my researching, I wants to confirm with you that
1. WinForm controls are not thread-safe, that is to say, you can not use
the controls in another thread if you create the controls in the Main
Thread.
If you wants to call the RichTextBox in the Main UI thread, you may need to
use the marshal the call back using Invoke or BegineInvoke.

Visual C# Windows Form Asynchronous Example
http://www.dotnetfun.com/Examples/Wi...usExample.aspx

2. Also there is more going on than just messages (API calls, etc) within
Windows Forms so you can't rely on Windows doing the marshalling. You can
have a separate form on a separate thread, but each thread needs to have
it's own message pump, etc.

Multithreaded Windows Forms Control Sample
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconDevelopingMultithreadedWindowsFormsControl.as p

If you have concern on this issue ,please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #9
Hi Mojo,

It seems that you post some issues in the newsgroup about richtextbox. So I
wants to confirm with you if you will show the richtextbox in the new
created thread, just as you create the richtextbox in main UI thread.

Or will you show the richtextbox in the Main UI thread?

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #10
Hi Peter,

Thank you for helping me out here!!!

I'm not going to show the RichTextBox in any threads.

I want to create a new RichTextBox in a seperate thread (not the main
thread) and do some text/rtf conversions and the tell the mainform the
RichTextBox.RTF text.

So I'm not going to show the RichTextBox in any threads only use it to
create som RTF, which I will send to the main form.

Best regards,
M O J O

Peter Huang wrote:
Hi Mojo,

It seems that you post some issues in the newsgroup about richtextbox. So I
wants to confirm with you if you will show the richtextbox in the new
created thread, just as you create the richtextbox in main UI thread.

Or will you show the richtextbox in the Main UI thread?

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #11
Hi Mojo,

So far I am understanding what you wants to do is to use the RTF and Text
properties of RichTextBox based on test, this will work in a new create
thread. I am not sure if you will do other operation on the RichTextBox.

Although we did not suggest you use a Winform Control in a non-GUI thread.
Anyway, if you have any concern on this issue, please post here, I am glad
to help you.
Regards,
Peter Huang

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #12
Thank you Peter for all your help!

M O J O

Peter Huang wrote:
Hi Mojo,

So far I am understanding what you wants to do is to use the RTF and Text
properties of RichTextBox based on test, this will work in a new create
thread. I am not sure if you will do other operation on the RichTextBox.

Although we did not suggest you use a Winform Control in a non-GUI thread.
Anyway, if you have any concern on this issue, please post here, I am glad
to help you.
Regards,
Peter Huang

This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #13

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

Similar topics

4
by: John Broderick | last post by:
I've got a problem with the RichTextBox control in .Net where the garbage collector doesn't reclaim its memory after I've finished with it. My program adds a series of rtb's to the control array...
3
by: zbcong | last post by:
hello i put a richtextbox and a button on the winForm.when the button is clicked,it generate several threads to write to the richtextbox,the code snippet as following: private void...
2
by: JRB | last post by:
I have a thread adding lines of text to a richtextbox on my windows form about every 1 second. I want the last line of text to always be visible, which it is until the box gets filled up. The last...
6
by: TGF | last post by:
I am wondering if it is feasible to use .NET for applications that have to be very fast. We have a few applications that are blazingly fast, written in Borland C++ using Borland C++ Builder. We...
5
by: mthgk | last post by:
I have a C# MDI app. The child forms do alot of work, so this work is perfomed on a different thread created using ThreadPool.QueueUserWorkItem(). Because the status of the work is important to...
1
by: Eric | last post by:
Using the 1.1 framework. We are using a newly created instance of a RichTextBox Class in our server code to manipulate RTF that is stored in the database. To clarify, we are not using or...
2
by: genojoe | last post by:
I want to transfer a copy of a RichTextBox to a thread but can't seem to find the right code. Something like the following seems logical but is not valid code. I have tried variations and did Web...
8
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have created a Control that extends RichTextBox to do syntax-hilighting. My strategy is to have a timer that restarts every time a user types a key so that it can wait until the user pauses for...
0
by: Linda Liu[MSFT] | last post by:
Hi CES, Thank you for posting here! I notice that you post a same issue in the microsoft.public.dotnet.framework.windowsforms.controls newsgroup and I have replied to that thread. For your...
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: 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:
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
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: 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
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
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...

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.