|
You can occassionally myForm.Update() to force a redraw, but that won't keep the UI thread responsive, it will only force a repaint.
If you want to keep your UI truely responsive (accepting input, etc.), you've really got 2 options.
1. Use a a background thread to do the work. This really should not affect performance greatly as you say it does.
2. Listen for Application.Idle event, and do a little of the processing each time you receieve the event.
Either way, your app will slow down somewhat because now it's doing 2 things: responding to input while painting the UI, and is also processing the logs.
Option #1 is good if you need to do lots of background work that cannot necessarily be split up into smaller tasks. It has the benefit of leaving your UI thread completely dedicated to handling UI requests, but has the downside of introducing possible complexity with thread coordination.
Option #2 is good if you can split up your work into small, discreet tasks that can be run individually. It has the benefit of simpler overall software, since you're only dealing with 1 thread still, but it also has the downside of making the UI thread do some work, which can potentially make your UI look sluggish.
|
|
|
|
|
Thanks for the reply!
I tried the myForm.Update() but, as you mentioned, I still don't have a responsive form. Threading the method wasn't terribly slow but it was a noticable drop in performance. Since the log scanning I do will be in large batches, I'll go with the threading route.
Thanks for your thoughts!
|
|
|
|
|
Hi
How can i get only the file name from string who consist full path?
best regards
when i want to read something good just seat and type it
|
|
|
|
|
fullPath.Substring(fullPath.LastIndexOf('\\')+1)
Is the MSDN really so hard to read?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: Is the MSDN really so hard to read?
No it isn't. Have you read it?
System.IO.Path.GetFileName
only two letters away from being an asset
|
|
|
|
|
So what? Both solutions will work.
My point is that it can't be so hard to open up the MSDN (local or online), go to the string or IO members and look if there's a function that fits my needs.
Nichts für ungut
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You're solution will work, so long as the path seperatation character is a backslash. This is not always the case and is not platform-independent. Using the correct method, pointed to by Mark, will work no matter what the platform or seperation character happens to be.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i am sorry but i really have not time to read it.Thank's for help
when i want to read something good just seat and type it
|
|
|
|
|
papa80 wrote: i am sorry but i really have not time to read it.
That's funny!! Looking it up on MSDN, or hitting F1 in Visual Studio, probably would have taken you 3 minutes to find the answer. How long did it take you to post the question on CP and wait for answer?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
string file = System.IO.Path.GetFileName(path);
|
|
|
|
|
I have a work flow management application for a publishing company. On projects with many contributers they use this application to manage all the submission. Sometimes a submission gets sent back to the author to be rewritten, in this case the document is to be attached to the email. I can get it attached and everything works ok, but in the email it has the generic icon and I have reports of it being labeled as an unknown file type. Once I save the document the proper icon appears and everything. Is there a way to set mime type so that it will appear properly in the attachment? Here is the code:
existingAssignment.Push(Convert.ToInt32(ddlCon.SelectedValue), "A", base.uid, dueDate);
Assignment currentAssignment = this.thisArticle.GetCurrentAssignment();
Contributor auth = new Contributor(this.thisArticle.AuthorID);
msg = new MailMessage(Session["ProjectEMail"].ToString(), auth.EMail);
msg.Bcc.Add(Session["ProjectEMail"].ToString());
msg.Subject = this.tbSubject.Text;
msg.Body = this.tbComment.Text;
msg.IsBodyHtml = false;
MemoryStream st = new MemoryStream(currentAssignment.FileBlob);
Attachment att = new Attachment(st, currentAssignment.FileName);
msg.Attachments.Add(att);
SmtpClient mail = new SmtpClient();
mail.Host = "localhost";
mail.Send(msg);
|
|
|
|
|
eggsovereasy wrote: I can get it attached and everything works ok, but in the email it has the generic icon and I have reports of it being labeled as an unknown file type.
I'm sorry, I guess I still don't understand. Where does this icon show up, and where is it generated from?
|
|
|
|
|
Well on my computer, in outlook I get it. The IT people messed up my office by installing Office 2000 over Office XP so I assumed it was an issue with my computer, but now I am getting some reports from other users.
The icon should just be placed on a .doc by the shell.
|
|
|
|
|
In C++ there are the following macros that can be put into strings....
__FUNCTION__ = Returns the current function that "__FUNCTION__" is in. Example "int Foo(int&,CString&)"
__FILE__ = Returns the current file that "__FILE__" is in. Example "C:\main.cpp"
__LINE__ = Returns the current line that "__LINE__" is in. Example 935
Is there something similar in C#?
Thanks Chris
|
|
|
|
|
chris175 wrote: Is there something similar in C#?
There isn't. However, you can retrieve some of this information programmatically. For example, you can retrieve any information about the current function using System.Reflection.MethodInfo.GetCurrentMethod() .
As far as the other things, regarding the file and line of code, there's nothing that can be retrieved programmatically, AFAIK, because once compiled, the file and line information is gone. The only way you could get this is by looking through you're application's PDB debugging database.
|
|
|
|
|
Hello!
I'm trying to create a custom-drawn toolstrip progress bar. The code looks like this:
public sealed class CustomProgressBarEx : ToolStripProgressBar
{
protected override void OnPaint(PaintEventArgs e)
{
}
}
The new paint method is called, but anyway the control still looks like a standard progress bar.
Any idea how to implement this? How can I draw the progress bar myself?
Best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
|
Hi All,
How would one loop a list view? and then after i've done what needed to be done with the item in the listview, move to next item...
i've started like this...
for(int a = 0; a < lvName.Items.Count(); a++)
{
}
Am i starting off correctly?
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
That's correct.
Another nice way is to use this:
foreach (ListViewItem item in lvName.Items)
{
}
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you.
I did not know you could use "foreach". I'll try it now.
Thank you once again.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hi, What do you call each item? is it the selected items?
because i need to assign the id of the client to a variable?
_CustomerID = lvName.SelectedItems[0].SubItems[2].Text.ToString();
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
NarutoFan#1 wrote: Hi, What do you call each item? is it the selected items?
This will iterate trough all items. You can also iterate though all selected items:
foreach (ListViewItem item in lsvReplay.SelectedItems)
{
item.SubItems[2].Text;
}
modified 12-Sep-18 21:01pm.
|
|
|
|
|
how can i create a mobile application in C# and what are the requirements
for any mobile application in C#?
|
|
|
|
|
yousufzai khan sanga chal day. Mobile applications lug the distributed systems background ghawari.
U will be using vs.net. Create new project C#->mobile device->pocket pc or smart phone etc.
you will be using the .NET compact framework. You will also be using the device emulator provided with vs.net during debuging ur software befor deploying to the real device.
Basic understanding of .net remoting,xml webservices,sync and async interaction is required.
i hope u will get start.
If u have further queries contact me at iqazi@gamesnetwork.net
ihtesham
|
|
|
|
|
iqazi wrote: Basic understanding of .net remoting,xml webservices,sync and async interaction is required.
These are NOT required to build a mobile application. They may be used, depending on the requirements, but again NOT a requirement for building any application.
only two letters away from being an asset
|
|
|
|