By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,156 Members | 1,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,156 IT Pros & Developers. It's quick & easy.

Using RichTextBox in a thread?

P: n/a
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
Share this Question
Share on Google+
12 Replies


P: n/a
* 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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.