|
Thanks, you're right I did cancel the close.
|
|
|
|
|
If you want an application to run from start to end like this you should use a Windows service, not a Windows form application, then you won't have this issue.
only two letters away from being an asset
|
|
|
|
|
Thanks for your help.
Now I got some error/strange window with caption:
.Net-BroadcastEventWindow.2.0.0.
What does it mean?
Thanks.
|
|
|
|
|
I want to remove a bottleneck using a second thread, but my thread dies but the object lives on..
So i don't seem to understand whats going with my thread let me try to explain:
Starter code:
<br />
msnthread = new Thread(new ThreadStart(StartMSN));<br />
msnthread.Start();<br />
Function code:
<br />
private void StartMSN()<br />
{<br />
start:<br />
try<br />
{<br />
if (Process.GetProcessesByName("msnmsgr").Length != 0)<br />
{<br />
Msnclass = new MSN();<br />
Msnclass.Cout += new MSN.cout(Cout);<br />
}<br />
else<br />
{<br />
Thread.Sleep(10000);<br />
goto start;<br />
}<br />
}<br />
catch (Exception e)<br />
{<br />
Cout("Fatal error: \n" + e.Message);<br />
Thread.Sleep(10000);<br />
goto start;<br />
}<br />
}<br />
After this code has run, the thread dies but the Msnclass keeps alive, but is it still threaded??
What am i doing wrong, also what would be a better way to restart instead of the goto start?
Thanks!
modified on Monday, October 19, 2009 6:23 PM
|
|
|
|
|
Hmm.
[EDIT]a finally block would always execute, resulting in one sleep too many. fixed that with a variable delay which also makes the finally block unnecessary
[/EDIT]
the normal way for retrying something is by setting up a loop which gets exited on success only. For instance:
for(int delay=0; ; delay=10000) {
Thread.Sleep(delay);
try {
...
break;
} catch(...) {
...
}
}
so no goto's, and a single sleep.
Scalee wrote: Msnclass.Cout += new MSN.cout(Cout);
I'm puzzled by this statement. Not sure what the intention is.
I'm pretty sure the cout should be a Cout (public identifier ==> PascalCase).
And it would be my guess cout() never returns for some reason.
suggestion: add a log statement right behind it; if that never executes, look at cout().
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
modified on Monday, October 19, 2009 6:00 PM
|
|
|
|
|
Aah no :P
You can ignore Cout it's an event, i can fire the event from the Msnclass and send messages to my main class to be printed
The thing still is that my thread dies and my object keeps existing which should be impossible...
Ill add some comments to the main thread if i still can.
|
|
|
|
|
OK,
I read it again, here are some comments and suggestions:
1.
please use PRE tags, not CODE tags, for showing multi-line code snippets.
2.
//check if msn is running if not abort isn't really accurate, as nothing gets aborted, something gets retried instead.
3.
assuming Cout(string) logs or somehow shows a string, add a Cout("going to create MSN") , a Cout("done creating MSN") and Cout("going to sleep") at the appropriate places. That way you will easily see what goes on.
4.
I expect you'll see the "going to create MSN" but no "done creating MSN", as the only location the loop can hang seems to be inside the MSN constructor, for reasons unknown as you didn't show its code.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Nope, there is no hanging.
This is how the application should be:
Main thread > running > mainform
Msn thread > running > msn class
What it is:
Main thread > running > mainform
Msn thread > stopped > msn class
Yet the class is still alive and usable, this is how i checked it:
toolStripMenuItem6.Text = "Msn status: " + msnthread.ThreadState.ToString();
toolStripMenuItem6.DropDownItems.Clear();
foreach (MsnWindow win in Msnthread.MsnWindows)
{
toolStripMenuItem6.DropDownItems.Add(string.Format("{0} {1} {2}", win.Name, win.History.ToString(), win.Window.HWND));
}
|
|
|
|
|
So there is no problem at all:
the MSNstart method has run to completion, hence the thread is stopped.
and the MSN object may be collectible (if no reference got stored somewhere by its constructor), and hence could possibly be collected by the GC the next time it runs.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Dear Sirs,
I need my project files to go to the right place. I currently have three projects. Project A depends on Projects B and C, both Class Libraries. Project B has a database file (MDB) in it, which copies properly to Project A's output (either Release or Debug \data) directory. Project C, however, the rogue, has a file in it and it copies to project C (!!)'s output folder. How do I get Project C to cooperate, and send its file (an XNA font file) to Project A working directory?
I wouldn't mind so much Project C copying its Content files to its own directory, but it can't find them from there: when the program runs, Project C uses Project A's active directory, so Project C complains, I can't find my file. I look around, and in Project C's directory, there it is, but the Exception says that it's looking in Project A's active directory.
I hope I have been clear enough. Thanks in advance for your help.
In Christ,
Aaron Laws
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
In Project C's properties, go to Build Events tab and use a post-build event command to copy the files to the necessary location.
only two letters away from being an asset
|
|
|
|
|
Dear Mr. Nischalke,
Thank you for your prompt reply. I noticed, however, that Project B (the working project which properly copies its database) doesn't have what you described. Why can Project B work and not Project C?? I'll try your suggestion.
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
I can only assume that VS know to copy the file as a dependency when you add a reference to the project. The properties of the file are probably set to copy to output.
only two letters away from being an asset
|
|
|
|
|
Dear Mr. Nischalke,
Thanks for you help. In both projects, B and C, the files in question are set to
Build action | Content
Copy to output directory | True
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
If you want further help, drop the Mr.
I've used commands like this to move files within my project folder structure
copy "$(TargetDir)$(TargetFileName)" "../../../Common/$(TargetFileName)"
only two letters away from being an asset
|
|
|
|
|
Hi,
Dll files may be copied to the output directory by setting the Copy Local property of the reference (right click the appropriate reference in solution explorer).
In general any file may be copied by right clicking, selecting properties and setting the Copy to Output Directory property.
Alan.
|
|
|
|
|
All well and good but this doesn't help his problem. This will place the files in the bin folder of the project, not copy them to another location, such as another project's output folder.
only two letters away from being an asset
|
|
|
|
|
Dear Mr. N,
I was very hopeful when I read this message, however, the problem-project is already marked True at the property in question. Thanks! I'll keep working on it.
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
Hi,
I couldn't find exact forum to put this question into so using this forum since it is a C# client. So here is the scenario :
I want to use a File based database in a C# desktop application. The database should be handle upto 5GB of data. Most of that will be due to images. Due to security reasons, I have to save the images in database.
Can someone please tell me some good choices for File based database?
Thanks
Pankaj
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
Umm, Access? I don't know about handling 5gig of data, but you can check out connectstrings[^]. They list every connection string under sun, which should give you good examples for databases I suppose.
|
|
|
|
|
EliottA wrote: Access?
What did he do to you to recommend this. Friends don't let friends use Access (or VB)
only two letters away from being an asset
|
|
|
|
|
Like Henry said, Microsoft Access[^]. Another option is SQL Server Compact, which is limited to 4Gb per database. Your best bet would be SQLite[^].
I are Troll
|
|
|
|
|
Whom are you calling Henry now?
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Elliot! Mea Culpa
I are Troll
|
|
|
|
|
You called?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|