|
but isnt the purpose of backgroundworker that u dont need to explicitly invoke the controls?
if i call worker.ReportProgress i dont need to invoke the controls and they are updated without cross threading exceptions!
i might have missed but idont see you calling worker.ReportProgress from your worker_DoWork method?
modified on Tuesday, August 4, 2009 11:37 AM
|
|
|
|
|
Two of the BGW events are handled on the main thread; and obviously DoWork is not, otherwise nothing would be going on in the background.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
Hello Forum
When you call Form.Close() the form actually closes but in fact it is still lives in memory, i need to make sure that when i close a form the from is dead and nothing is being executed any more on this form, is the way to achieve this by invoking the GC.Collect() or there is another way.
Please help
Thank You
|
|
|
|
|
there is no other way!
but you need not call GC.Collect(), the system does it regularly when it's idle and memory is low (or other propitious condition)
however, for testing / debugging purpose, it's good to call GC.Collect() and the use some kind of memory profiler to see if some unexpected object stays in memory.
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi,
a Form doesn't do anything, neither do any other .NET object.
The only things that do something are Windows timers, Windows events and Windows threads.
So if your Form did launch a timer or a thread (incl. BackgroundWorkers and asynchronous I/O operations) you should make sure they come to a halt; having the Form collected is both unnecessary and insufficient.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
right, i had some timer's and upon closing i stoped them, but i was wonderig if thre is a way with one command stop them all, this is why i was going in this direction.
Thanks for your help
|
|
|
|
|
Write the timer stop code in Form's dispose method. Also consider using background threads to do the processing. Background threads will terminate when the parent thread terminates.
|
|
|
|
|
great idea
thanks
|
|
|
|
|
I can add text, data values from the database into a word file through the C# coding. I want to know how to insert an image in the word file through c# coding?Plz help urgently!!!!
csetopper_bhanu
|
|
|
|
|
Hi,
Please let me know the difference b/w abstract and Interface...with example...
im confused......
|
|
|
|
|
|
Hello all ,
I have couple of questions .
1.why do we need to call forcibly Garbage Collector when we dont know which object is going to be destroyed ? I mean i would like to know the scenarios where exactly we need this .
2. i have requirement that i need a custom class in which i can destroy the class when needed. is it possible ? if yes can u lease give me code to do it .
3. How can i say this resource is Unmanaged and this one is managed ?
Apologises incase of trouble.
Regards,
Jaddu
|
|
|
|
|
1) One scenerio would be an application that creates several temporary objects that need to be cleaned up occasionally during the apps lifetime to prevent memory leaks and performance degradation. A graphics editor could be an example.
2) Use the Dispose pattern[^]
3) Start here[^]
only two letters away from being an asset
|
|
|
|
|
1 - Mostly you don't need to use this method. I have only used it to test the language/framework features. Here[^] is a decent blog post on the subject.
2 - You can't reclaim the memory allocated deterministically. It is handled by GC. If you have critical resources that needs deterministic cleanup, use Dispose[^] pattern.
3 - AFAIK, there is no good way. Usually framework classes implements IDisposable to say it has got something to cleanup. In C#, you can't use unmanaged classes directly. You use it using P/Invoke. So if you are seeing P/Invoke calls, there will be unmanaged code involves.
|
|
|
|
|
Hi all,
i am just monitoring the URL changes, using SHDocVw.InternetExplorer
is it possible to hide the context menu
i have used the following event like bellow:
((mshtml.HTMLDocumentEvents_Event)document).oncontextmenu += new HTMLDocumentEvents_oncontextmenuEventHandler(clsURLMON_oncontextmenu);
bool clsURLMON_oncontextmenu()
{
return false;
}
it disbles but does not allow any links to proced and entry as well
can some help me......
thanks a lot.
|
|
|
|
|
Hi all...
I'm representing an XML file through TreeView.
I load the XML file as an XMLDocument and then transform the XMLNodes into TreeNodes to build the tree... so I have a tree of XMLNodes (the XMLDocument ) and a tree of TreeNodes which have the same formation.
My question is: if I'm selecting a TreeNode how can I reach/address it's XMLNode at the XMLDocument , do they share a common path??
|
|
|
|
|
reilak wrote: do they share a common path??
Yes,
first change change properly the value of PathSeparator property of the TreeView to / and next use XPath expressions to access your document calling XmlDocument.SelectSingleNode with TreeView.SelectedNode.FullPath property.
|
|
|
|
|
Ok, I retrieve the full path of the treeNode and use the string.replace() method to change the PathSeparator from '\' to '/', the thing is that I have a problem with this representation "\" of the \ character, it's like I didn't close the string, why?
EDIT:
string TNpath = treeView1.SelectedNode.FullPath;
TNpath.Replace("\", "/");
|
|
|
|
|
Hi, character '\' is special character it need's to be escaped
use TNpath=TNpath.Replace("\\", "/"); instead of TNpath.Replace("\", "/");
|
|
|
|
|
It gets the full path, including the file path, and it cause an XPath error. ):
|
|
|
|
|
You would better start learning XPath from here.
|
|
|
|
|
hi!
i have a very weird problem:
i have an app which listens for connections, and once a client connects it starts anothter app,
now if the main listening app terminates but app2 is still running then the port isnt released and when the main app starts up again and try to bind to the port it fails (port already in use).
the port is first released when app2 or all of its child processes has terminated, but these processes has nothing to with the main app, so why isnt port released after the main app has been terminated?
|
|
|
|
|
After little more investigation with process hacker (Process Hacker/[^]) i see that the apps started from the main listening app and there child process gets the handle to the named pipes and somthing called \device\afd that main app has created, if i close those handles then the port is released, if i dont then the main app actuallty keeps running and listening on that port according to process hacker but doenst respond to incoming connections.
so the main app, after its terminated doenst show upp in process list/taskmanager or netstat tool but shows up as UnknownpProcess in process hackers "network connections" listening on the port??
How can i fix this?
This is how the app currently works...
My App --> starts app2 and creates pipes. Now if my app gets terminated then app 2 is also terminated, but i have no control of which apps app2 might start and they are not terminated once app2 gets terminated so they keeps the handle to named pipes and (mainly)device\afd and keeps the port busy?
|
|
|
|
|
the problem was that all processes was inherting sockets handle
Anyhow i thought i might post the solution if any1 else have same problem, simply use SetHandleInformation [^]thru pinvoke!
|
|
|
|