|
People may need to see the relevant code, in order to help you out.
|
|
|
|
|
I am sorry, I am not authorized to share the code. Also I cannot produce similar sample of code. Its too big and complex to understand. And I myself have just 1 month of experience in .Net.
This problem is very specific. Someone if know the things to be taken care about Application-Domain and MarshalByRefObject while calling functions from external assembly?
As objects derived from MarshalByRefObject are not getting collected by Garbage Collector, there could be some special way of freeing them from memory.
|
|
|
|
|
Have a read of this[^] article and pay particular attention to the lease management.
|
|
|
|
|
Seems I was unaware of the potential problems with MarshalByRefObject.
Here[^] is another article you may want to read.
|
|
|
|
|
I would see stuff like this when I was using mixed (managed C++) code. What I found was that the references to the called DLLs were not being released unless I unloaded them by hand.
So, what you might try is loading the DLLs dynamically in your C# app, then unloading them and setting their references to null when finished using them. Each time a DLL function is called, you might then reload the DLL, but this might help you get rid of your memory leak.
|
|
|
|
|
Once an assembly (a .Net dll) is loaded, it cannot be unloaded and so it will remain in application's address space until process's life time. To avoid this we should load an assembly in a separate application domain. An application domain can be unloaded whenever we want and while it unloads, it also unload all assemblies loaded inside it. So problem can not be resolved as you said. But yes, as you said we have mixed code of Unmanaged C++, Managed C++ and C#. Could this mix of code have any implication?
|
|
|
|
|
To be 100% sure what the problem is, crack out windbg with the SOS extension for .Net. You can use ADPlus to take a memory dump of the .Net process in question, and then load the dump file into windbg.
The SOS debugger extension is used for debugging .Net memory dumps. Using !dumpheap -stat will show you all instances of objects on the heap. Given an instance handle, using !gcroot <handle> will tell you which thread is keeping the instance alive. Using !clrstack for that thread will show you the stack for that thread, pin pointing the exact code.
These commands are only the tip of the iceberg though, check out Tess Fernandez's blog at http://blogs.msdn.com/b/tess/[^] for help on using windbg for memory leak debugging in .Net.
|
|
|
|
|
Hi everyone,
I have a question about how to handle Thread.Join( ) and the cases where the thread is updating using Invoke.
The problem is my background thread calls back into a method periodically that uses Invoke() to update some GUI elements. Now, when I call Join() on my background thread (in response to the user cancelling the job and the application waiting for the thread to finish), the whole application hangs as the subsequent Invoke() calls never return because Join() is blocking the caller thread (i.e. my main thread).
Does anyone know how I can get around this? Thread.Sleep() is no use either as I do want the main thread to be responsive and at least handle these UI events. I was under the impression that the message pump was supposed to be active when using Thread.Join()
Cheers,
Pankaj
|
|
|
|
|
Why would you need Thread.Join() in your main thread? As I told you recently, the main thread should never take long and should never block. Thread.Join() is OK when one background thread needs to wait on another background thread, you should not use it in the main thrad.
If your main thread needs to know some background activity is finished, use another mechanism; however most of the time, you should not be interested in when exactly the background activity finishes, all you need to do is set a flag that tells it you are no longer interested, which allows it to exit early and tells it not to produce anything anymore (yes, your code now needs to test that flag on every action you don't want to go on).
|
|
|
|
|
I have 2 suggestions:
1. Do not use the Thread class unless you have to, because it adds a lot of complexity (could BackgroundWorker do the job?)
2. I would never use Thread.Join() unless I really had to... What if you just set a flag to notify the background thread about the cancellation and wait for the thread to complete without calling Join() ?
|
|
|
|
|
Just because you call a join does not mean that the function that you are running is terminated. When calling join, the caller (in your case the background process) will block indefinetly as long as the thread has not terminated. If the thread is completed, then the join method will end immediately. To fix your problem, ensure that you are exiting the function that is running in the background thread when the user 'cancels' the request.
|
|
|
|
|
As others have said, I also recommend the BackgroundWorker , b/c it works very well and was designed to be used in conjunction with a UI. I'm curious, however, why you need a background thread at all if you do not want your GUI to be responsive. You could just do everything in the main thread if you don't want the GUI to be responsive.
Also, have you considered setting Enabled = false on controls you do not want the user clicking (since you don't want them messing with things). An easier mechanism is to put controls in a panel (or container) and set Enabled = false on the panel (or container). This way the GUI is still responsive (no stupid white "not responding" window) but the user can't update / click fields either.
|
|
|
|
|
Hi,
Hope this is the right place to post this issue. If not, please let me know the right place.
I'm using Visual studio 2008. I'm trying to create setup file for my application. In File System properties, while adding a shortcut on User's desktop it is not showing any dialogue box to choose the exe from "application folder".
I continued ignoring that dialogbox and installed the setup. I found a shortcut icon on desktop. On clicking that it opened Desktop folder.
Please let me know where I missed. Thanks in advance.
|
|
|
|
|
BradNorth wrote: Hope this is the right place to post this issue.
I may be wrong but this does not sound like a C# issue.
It's time for a new signature.
|
|
|
|
|
Hello All,
I am creating a xml file programatically but it is saved as .dtl.
I have no Idea how to assign a ICON to saved file.
Plz guide me.
Thanks in advance
|
|
|
|
|
And I assume you want to do this programmatically? Check out this[^] CP article.
|
|
|
|
|
Thanks for your Reply.
Is ther any dot net APi to do so?
|
|
|
|
|
Is there on codeproject or other introductory articles on technical issues in C# application development and deployment with MS SQL express 2005/2008? like db creation and attachment to application with connection strings for SQL authorization, setting folders security to access it with SQL authorization from application and finally deployment from setup?
Чесноков
|
|
|
|
|
Hi......
I am having problems while connecting to Vector CANdb database file in C#.Net. It gives an error
"Object or provider is not capable of performing requested operation"
So, how to achieve it?
Thank you.
|
|
|
|
|
Hi,
how do try to connect to the DB? Could you post the code? I guess that you are using the wrong client library.
Regards
Sebastian
|
|
|
|
|
You proably don't have a provider installed that supports CANdb databases.
You'll either need to find a provider that supports that database format or a library that handles all database access for you. I don't know of any.
|
|
|
|
|
Hi,
i have a windows service having a udp server, tcp server and a serial server all acquiring GPS data from remote devices. After data is acquired it is parsed for validity and processed into defined objects. Now this data has to be relayed to multiple client UI's which can be running on a local or a remote machine. Previously i used MSMQ for data sharing between different processes but i seem to be having some problem with connecting to remote machines. So i decided to switch to .net remoting. Its my first take on remoting so kindly bare with me.
I have to share that real-time parsed objects with multiple clients with minimum latency.
The channel between server and client should allow 2-way communication between client and server in the form of a string and objects.
I wish to inquire which type of object activation should i use.
Thanks in advance.
|
|
|
|
|
isso é bem simples, basta declarar um vetor com ponteiro multiplo e chamar o método Add() dentro do seu ânus
|
|
|
|
|
Hi everyone,
I am trying to update some UI periodically through the use of Application.DoEvents() in response to a timer callback. However, I am having a bit of trouble getting it to work.
So, I have a dialog box that is created in the main thread. I have a long running method in a third party control and all I want to do is make sure that the dialog box stays responsive to mouse movements and can respond to move events etc. I know I should be calling the long running function in a background thread but due to the idiosyncracies of the software design and third party tools, I am unable to do so.
So what I thought I would do is create a Threading.Timer object and have it send periodic events to my dialog box and ask the message queue to process the messages.
This scenario is as follows:
m_timer = new System.Threading.Timer(new TimerCallback(TimeElapsedHandler),
null, System.Threading.Timeout.Infinite, 100);
m_timer.Change(0, 100);
The timer handler is as follows:
private void TimeElapsedHandler(object state)
{
System.Windows.Forms.Application.DoEvents();
}
In the debug mode, I can see this event getting called during the processing. However, the DoEvents() call is not really updating the dialog box as it should.
Now, the strange thing is that when I add some Application.DoEvents() in the callbacks that I get from the third party call, the update is as I would expect it (I cannot rely on these updates to come frequently enough, hence I need a regular periodic solution).
The puzzling thing is that the timer and the dialog box is created on the main thread. So, I am puzzled as to why my update is not happening.
I would appreciate any thoughts or input you might have on this.
Best wishes,
Keith
|
|
|
|
|
Ok, it seems that the callbacks are from another thread..
I called Invoke and tried to update using that but this, of course, just gets queued and never gets fired till the long running method returns.
Any thoughts anyone?
Thanks,
Keith
|
|
|
|