|
You cannot set the Text property of your rich textbox from another thread as the one it was created on. You should first create the content string (you're better of using the StringBuilder class by the way, it's faster) and then assign it to the rich text box's Text property from the thread it was created on.
Standards are great! Everybody should have one!
|
|
|
|
|
hi,
to access the object's properties created in one thread from another, you have to define a delegate for that function and invoke that method from the new thread. then only you will be able to change the properties.
example below:
private delegate void UpdateUIDelegate(string text);<br />
private void UpdateUI(string text)<br />
{<br />
if(InvokeRequired)<br />
{<br />
this.Invoke(new UpdateUIDelegate(UpdateUI),new object[] {text});<br />
return;<br />
}<br />
this.textbox1.Text= text;<br />
}
you can now call the "UpdateUI" function from the new thread
this is one of the methods of making your code thread safe.
hope this helps
regards
|
|
|
|
|
I have been looking for many article about writing text file but all of those they talking about window form but I'm looking for web application article and I don't find any.
I would like to get help from anybody who knows how to do this work.
And also I have a question.
-Can I use streamwriter or streamreader with web application?
Please help me give up with this problem.
Thank you for all reply,
Junior boy.
-- modified at 3:44 Monday 21st May, 2007
junior boy
|
|
|
|
|
It's irrelevant that it's a web app, assuming you want to write a text file on the server. On the client, all you can do is have someone download a text file, you can't just write one without the user asking for it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You mean I have to create a text file and keep it on the server first and then if user want that file just download from the server and I can't write the information directly to client,right?
And please give me some keyword for looking the ideal of this.
Thank you very much.
junior boy
|
|
|
|
|
You can do that, then you just need to provide a link. You can also set the mime type and stuff a file into a response, using the Response object.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi!
I do have strange crashes on an application.
An App, consisting of an .Net1.1/C#-Exe and some .Net1.1-DLLs is doing some communication over RS232 and executing some Threads/UserWorkItems. It processes some Jobs, that are started by commands that arrive over RS232.
At some point, when the app is running maybe about 45mins to 1.5 hours it disapperard without any sign. I put in a lot of logging (Status of the system, exceptions and so on), so there should be nearly no line of code outside a try/catch. Every try/catch-block has it´s own logging.
I even put a try/catch around the "Application.Run(...)" inside my main-routine. Logging before and after this application start should show me, what happened. No result: the app doesn´t even write the logging at the very end of the main-routine where any exception should be caught.
But when the app crashes i do not get any more logging-entry or event this nice "MS-Send Information on crash"-Window. It´s just gone, just if anyone killed the process with the task-manager.
And what the stangest thing is: it works fine for hours and hours on an simulation-worksstation, but crashes on the machine it should finally run on.
Who can help me? Any ideas are welcome!
Thanx a lot!
J.
|
|
|
|
|
Hi,
Assuming your application is multithreaded, its very much possible that your crash issue is related with thread synchronization.
You look for possible thread synchronization problem in your code. Also you can implement a debug writer to a file system which will write the debug message to a physical file (Debug file). When your application crashes, you can go through the file and find out what is the last few lines of code excecuted while crash occured.
Manoj
Never Give up
|
|
|
|
|
I do have a debug-writer. But i always get different code-lines with that.
The thread-sync is done by events, that are sent between the threads (this is because of the architecture and the needs of the app). Each class takes handles events it receives.
What i got a few minutes ago was a "ExecutionEngineException" while closing a Logging-FileStream.
Maybe this could be a hint on where the error might be...
|
|
|
|
|
|
Try this[^]
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
I am a C# beginner.
when attribute changed,I want to start a event for response.
like VisibleChanged event.
I mastery is bad about event and delegate,please guidance.
Thanks very much.
|
|
|
|
|
Use a delegate and add it to the event for your object.
TextBox txt = new TextBox();<br />
txt.VisibleChanged += new EventHandler(TextBox_VisibilityChanged);<br />
<br />
public void TextBox_VisibilityChanged(object sender, EventArgs e)<br />
{<br />
}
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
My Class :
public class MyClass
{
private int stauts =0;
public int Stauts
{
get{return status;}
set{status = value;}
}
}
How write a event associate "Stauts" when "Stauts" changed.
thanks.
|
|
|
|
|
hi,
you could try the following:
public class MyClass
{
private int stauts =0;
public delegate void MyEventHandler(object obj);
public event MyEventHandler OnStatusChange;
public int Stauts
{
get{return status;}
set
{
status = value;
OnStatusChange(this);
}
}
}
for more information read http://www.codeproject.com/csharp/eventarguments.asp[^]
regards
|
|
|
|
|
why "MyEventHandler" does not have "EventArgs" parameter?
|
|
|
|
|
Call the event hanlder inside the body of the set{ } statement.
|
|
|
|
|
the declared sentence: "public event StatusHandler statusChanged",
where should i write it?
thanks.
|
|
|
|
|
I have a very basic upload/download application. The app uses a select statement to download and a insert statement to upload. The reason I include those is because I am not sure how to get a progress report from them, ie completion percentage. I may be uploading upward of 100megs and don't want the user to just sit there waiting. I have tested a 5meg file and it takes about 3 minutes to upload and does so correctly, but the user has no idea what is going on.
How do I get progress of the SQL read/write so I can update my progress bar?
Thanks in advance!
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
I am not aware of a way to do this, but it has been my experience that as long as users see the progress bar moving they know the application is not hanging and feel some better. So estimating the % complete based on seconds elapse divided by (average megs per second * megs) should be a reasonable solution (I swear microsoft often does things like this). Just make sure that the last 5% of the progress bar moves much more slowly and stops at 99% so that you don't reach 100% before it's done.
topcoderjax
|
|
|
|
|
:(hi all,
in my window form i m bindng one datagrid with check boxes now i wnat to dele those record which are checked how i can do this in window C#
i m also bind the image of the member into datagirdview(images are in the DB)
how i can perform this
regard
|
|
|
|
|
Hi,
Deleting records:
You can follow the following steps to get the "checked" records deleted.
1) First get the records marked "checked"
2) Use the dataGridView1.Rows.Remove to remove the data from the Grid.
3) Use the SqlCommand to get the records deleted from the database.
Binding Images:
I have bound a image column from the access database with the "datagrid" automatically from wizard. Please note that the type of the column in data table is Ole Object.
Manoj
Never Give up
|
|
|
|
|
hi,
i'm trying to parse C# file and want to change the code..
i have a class with following lines of code, assume
class Test
{
public void method()
{
Foo.Bar = "Demo";
}
}
i want to extract only the property name and its value..
i have a pattern like this.. which extract the value only, but i need the property name too..
<code>
"\\Foo.[^;]*(=\\s*\")(?<val>([^\"]*))";
</code>
plz give me a pattern which extract the both.
regards,
nas
|
|
|
|
|
We are using SQLDbAccess.dll provided by Microsoft. There are two methods are filling the Dataset. Fill method and also ExecuteDataSet. Which one will be better? Thanks
|
|
|
|
|
K.P.Kannan wrote: Fill method and also ExecuteDataSet
If your taking about DataAdapter.Fill then it is better to use the ExecuteDataset method as the SQLDBAccess.dll would look after opening/closing connections
|
|
|
|