|
Did you check the Application log in Event Viewer? My guess is that something seriously wrong happened within your app that caused the OS to terminate it immediately. Usually, it will be logged in the Application Log, so I'd suggest you take a look there.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi All:
Been reading all I can find about multi-threading in Windows Forms, but still cannot wrap my head around this topic. Thanks in advance for any assistance!
1. Need to update a progressbar control on a SDI application while the form reads a text file. The progress bar is just a simple visual indicator to inform the user that the application has not "frozen". Pretty basic stuff.
Have consulted the following resources but still don't understand,
2. Multithreaded Windows Forms Control Sample from microsoft's website
3. http://www.codeproject.com/csharp/launchprocess.asp
Be happy to answer any/all questions.
Regards,
Keith Eckstein
|
|
|
|
|
Where exactly are you facing problems? All you have to do is to do the file reading on a separate thread (created via System.Threading.Thread or through Delegate.BeginInvoke) so that you will not hold up the UI thread. Updating the progress bar is just a matter of setting the appropriate progress value as you keep reading the file, for example, you could set max value to the number of lines in the file and then keep incrementing the progress value as you read the file line by line.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi Senthil:
The deal is I have a Read function that reads the file line by line and returns the contents of the file to a text box in the form. I need to update the form's progress bar (on the UI Thread).
A. the function to increment the progress bar.
1. private void progressBarUpdate()
2. {
3. //Reset to start if required
4. if (this.progbar.Value == this.progbar.Maximum)
5. {
6. this.progbar.Value = this.progbar.Minimum ;
7. }
8. else
9. {
10. this.progbar.PerformStep();
11. }
12. }
B. the delegate
13. private delegate string ReadDelegate(string file);
C. the function that reads the file, line by line.
14. private string Read(string file)
15. {
16. StreamReader reader = new StreamReader(file);
17. string strBufferFormatted = String.Empty;
18. string strLine = String.Empty;
19. int intLines = -1;
20. while(reader.Peek() != -1)
21. {
22. strLine = reader.ReadLine();
23. intLines++;
24. //update the progress bar here
25. BeginInvoke(new MethodInvoker(progressBarUpdate));
26. strBufferFormatted = strBufferFormatted + strLine;
27. }
28. this.lblLinesUnformatted.Text = intLines.ToString() + " lines read.";
29. reader.Close();
30. return strBufferFormatted;
31. }
The form is unresponsive while the file is being read, only after the file is read do the progess bar's blue blocks increment.
What am I missing?
Regards,
Keith
|
|
|
|
|
mtbchef1 wrote: private delegate string ReadDelegate(string file);
Did you paste the whole code or just sections of it? I'm guessing from the declaration of the delegate that you are doing something like
new ReadDelegate(Read).BeginInvoke(fileName, null);
somewhere in your UI event handler? If not, you need to do something like the above. If you instead call Read directly, the UI thread remains blocked until Read completes, so any UI updates you make, including progress bar updates, will not be performed.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi Senthil:
What I have are these lines in the Click event of a button:
// Spin off a new thread to update the ProgressBar control
ReadDelegate dlg = new ReadDelegate(Read);
dlg.BeginInvoke(this.txtFile2Parse.Text, null, null);
the Text Box on the form (this.txtFile2Parse) contains the full path and file name of the file to read.
Still have no clue how this stuff is supposed to work. Apologies for being so dense...
Regards,
Keith
|
|
|
|
|
|
Hi,
I am developing an implementation that needs to disable TCP-IP on a network adapter and at the same get the MAC address of the same network adapter.
Currently I am getting the MAC address using the GetIfTable call from IPHlpApi.dll, and manually disabling TCP-IP from the adapter properties as soon as the MAC is acquired. (GetIfTable returns 0 when TCP-IP is disabled).
My aim is to keep using the GetIfTable,get the application to disable TCP-IP exactly after it gets the MAC, and renable it when the application is closed, however I have no clue how to automate this.
Any help or new ideas greatly apreciated.
Kind Regards,
Dav
|
|
|
|
|
i've created a contro with this property, i let the user can select an image for the control.
During the design time, it works.
But when i compile and try it on another pc i the image is not loaded.
So what i've to do after i load the image?
[EditorAttribute(typeof(MyFileNameEditor), typeof(UITypeEditor))]
[Category("Image state"), Description("Mouse over image")]
//[DefaultValue("")]
public string MouseMovePath
{
get
{
return MouseMove_path;
}
set
{
try
{
MouseMove_path = value;
FileStream fs = new FileStream(MouseMove_path, FileMode.Open, FileAccess.Read);
move = Image.FromStream(fs);
fs.Close();
this.Invalidate();
}
catch
{
MouseMove_path = "(none)";
}
}
}
|
|
|
|
|
I don't see how this would work properly. Your Image is being loaded from a FileStream that you're immediately closing with fs.Close() . An underlying stream has to be open for as long as the Image is in use. The next call to Invalidate() makes it try to refresh the image... but it can't, so I would expect an error thrown at that point.
--
I've killed again, haven't I?
|
|
|
|
|
Hi, I want to make the tab for my program flash in the taskbar, I have done some googling, and found the following code:
using System.Runtime.InteropServices;<br />
<br />
[DllImport("user32.DLL", EntryPoint = "FlashWindow")]<br />
public static extern int FlashWindow(int hwnd, int bInvert);
But unfortunately I have not been able to get it to do anything (calling it has no effect), in fact I don't even know what the int parameters refer to. Can anybody give me a prod in the right direction?
Thanks!
Martin
|
|
|
|
|
According to pinvoke.net the second parameter should be a bool. FlashWindow[^]
There's also a FlashWindowEx[^] function which might be more suitable for your needs.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
Ah, most helpful, thank you very much!
|
|
|
|
|
Hi.
I need a complete article about software layers.
Best wishes
|
|
|
|
|
Write one 
|
|
|
|
|
Hi.
I have a table in SQLServer 2005, that has two fields (Name,Family), for example.
I want in C# (VS 2005), write some lines of code to add a record to this table.
How can I do it?
(All in code)
Best wishes
|
|
|
|
|
|
Is there some code snippet that would reset local IIS when used?
Something like this one that starts browser from Windows application:
Process p = new Process();
p.StartInfo = new ProcessStartInfo("http://www.nba.com");
p.Start();
Tnx!
|
|
|
|
|
Process p = new Process();
p.StartInfo = new ProcessStartInfo("net", "stop w3svc");
p.Start();
p.WaitForExit();
p.StartInfo = new ProcessStartInfo("net", "start w3svc");
p.Start();
p.WaitForExit();
You can use net start/stop with any of these (taken from here[^]):
Iisadmin IIS Admin Service
Msftpsvc FTP Publishing Service
Nntpsvc Microsoft NNTP Service
Smtpsvc Microsoft SMTP Service
W3svc World Wide Web Publishing Service
|
|
|
|
|
Tnx a lot man, I owe you one 
|
|
|
|
|
Hello,
Is there a way to create native exe from VS.NET? I have an application that would be used by a client who I don't think would have .NET framework.
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
You can't create a native exe from a .net language (without spending some money at least). If you want a native exe you'll have to write it in C++.
|
|
|
|
|
There's Bartok by Microsoft Research, but it's not available to public.
Best bet would probably be to tell them that the framework is part of Windows Update 
|
|
|
|
|
I haven't seen non-commercial product but there are commercial products (like this one) that can produce native executable from .NET code.
|
|
|
|
|
i have a problem in writing a c# code for steganography detection and estimating the hidden message length for color palette images using Ezstego algorith written by J.fredrick or any other algorith if this is not availabe i need clues to begin writing the code please as soon as possible
na
|
|
|
|