|
Hi,
I developed a windows application.Now after installation it should be shown in system tray beside date & time. Then on the right click of this i have to show some options like enable/disable.
Iam new to c#.Kindly help me on this.
Thanks to all
bye
|
|
|
|
|
Can NotifyIcon[^] help you?
I died as a mineral and became a plant,
I died as plant and rose to animal,
I died as animal and I was Man.
Why should I fear? When was I less by dying?
-- Rumi[^]
My blog
|
|
|
|
|
Hello,
I'm puzzled with a simple issue in finalizers. If I have a class containing a reference to an object, isn't it supposed that the referenced object isn't applicable for GC collection except after my object is finalized?
|
|
|
|
|
Not at all. As soon as there are no active references to your object, the reference to the other object is also considered inactive. If the other object doesn't have a Finalizer, it's very likely that it will be garbage collected first.
You can't rely on the order that the objects are garbage collected, so you can't use the Finalizer for cleanup. That is what the IDisposable interface is used for.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yes, I read about that, but it doesn't make much sense to me. Regardless, what can I do if I need to enforce an order for finalizers? Both objects have critical finalizers, but one of them must run before the other; otherwise an access violation occurs...
Thanks for your help
|
|
|
|
|
|
Thanks for your help. I read a lot about the Disposable pattern, and I implement it (according to the Disposable Design Principle[^]). However, I'm writing a library, so I don't actually control the order of calling Dispose methods. I tried to encapsulate it, but then I ran into referencing objects in the finalizer...
Another issue is when the application is rudely unloaded; my (critical) finalizers must run in the correct order, or else the (external) library I'm using would cause an access violation.
I thought about having all the finalization logic in one class, but I had to maintain a list of delegates to be called during finalization. Now this list is again a managed object, so I shouldn't be referring to it!
I'm confused!
Thanks again.
|
|
|
|
|
Your only chance is to use the Dispose pattern and propagate it down your object graph(s), and additionally use try/catch logic in the appropriate places. Finalizers for sure will lead you nowhere since - as stated above - they are indeterministic in order.
The logic may become complicated depending on what you are doing - but there has to be one.
HosamAly wrote: Another issue is when the application is rudely unloaded;
If that means 'crash' or 'cancelling the app via task manager' there's exactly nothing you can do. (Anyway, this is exceptional and not part of a programs normal behaviour, so you're not really to blame for things that happen in this case.)
Regards
Thomas
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Hello,
I want to access the remote computer from anywhere through internet like remote desktop.
So, I just need to know whether it is possible to do remoting on web?
Reply me its urgent.
|
|
|
|
|
krinaljariwala wrote: Reply me its urgent.
We are your servants or employees or something ?
Regards
Thomas
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Thomas Weller wrote: We are your servants or employees or something
We must be far worse. Even employers don't put the word urgent when asking a solution for something like "Web Remote Desktop"
-------------------------------------------
It's code that drives you - Shyam
|
|
|
|
|
What about 'slave'?
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Thomas Weller wrote: What about 'slave'?
That fits it . Though he can't lash us with his whip or anything.
-------------------------------------------
It's code that drives you - Shyam
|
|
|
|
|
Thomas Weller wrote: or something ?
Maybe a Genie[^].
I died as a mineral and became a plant,
I died as plant and rose to animal,
I died as animal and I was Man.
Why should I fear? When was I less by dying?
-- Rumi[^]
My blog
|
|
|
|
|
That's one possible interpretation. (I see that a lot here.)
Another possible interpretation is that it's really urgent. (You do realize that's possible, don't you?)
|
|
|
|
|
Alan Balkany wrote: You do realize that's possible, don't you?
Of course I do.
But it's a matter of good/bad behaviour, not of possibility. Would you talk to people that way if they were physically present, no matter how urgent it might be? And how would you expect them to react on your person in this case?
Regards
Thomas
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
|
|
|
|
|
krinaljariwala wrote: Reply me its urgent.
Urgent Reply: Yes sir, it's possible.
-------------------------------------------
It's code that drives you - Shyam
|
|
|
|
|
You needed 34 minutes for that reply? Shame on you!
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Since he said it was urgntz, it took 34 minutes for me to research this whole thing on CodeProject, Google, MSDN, My own stupid blog, etc. etc. and finally, I found the codez... so since I have codez with me, the answer is yes
-------------------------------------------
It's code that drives you - Shyam
|
|
|
|
|
Didn't you forget some z somewhere ?
Plz help me with that, it's very urgntz.
I'm in danger of failing my class! Plzzzzzzzzzzzz!!!!!!
(If there was only a cent for every incorrect z on CP, oh my... )
Regards
Thomas
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Ok.... willz addz az many z'z az you needz.
Thomas Weller wrote: If there was only a cent for every incorrect z on CP, oh my...
One of the few ways to become world's richest man
EDIT
With my post, you get 8 centz.
-------------------------------------------
It's code that drives you - Shyam
|
|
|
|
|
Hi,
I want a class to have a pointer to a local variable of another class to change it later. In C++ I do it this way:
class AClass
{
public:
int *m_pInt;
AClass(int* pInt)
{
m_pInt = pInt;
};
void SomeFunc()
{
*m_pInt = 20;
};
};
class B
{
int x;
AClass a(&x);
};
Is it possible to do this in C# using safe types?
I'm still new to C#, so excuse me if this is a dumb question.
"In the end it's a little boy expressing himself." Yanni
|
|
|
|
|
There is no such thing as a 'Pointer' in C# - for very good reasons.
Yes, what you are trying to do could be done some way or the other. But what is it you are trying to do ? A class should never have access to another classes internal state, this neglects the whole idea of OO programming and encapsulation.
Regards
Thomas
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Thomas Weller wrote: this neglects the whole idea of OO programming and encapsulation
True. Ironically enough I'm trying to solve a design issue using this method. I'm tired of the large amount of code behind each and every dialog or form due to interactions with controls inside a form. I decided to do this:
1. For each stored procedure of my database I have a set of data that needs to travel between layers of application, so I create an app that generates code for both stored proc and the data it needs or provides. Almost all procedures that work for each table have similar data, so I thought about a class that can hold all data related to each table or a specific task.
2. Most of the time, same data that a sp needs for saving or provides on loading will be shown in a form or gathered to be saved from a form.
3. Instead of using the form to control everything, when instantiating controls, what if I tell them where to store data. I have an instance of the class which is responsible for trnsfering data. It has one member variable for each control. I give access to members of this class to each control. Each control then saves user input in this class instead of holding a local state.
4. Now if I set an object for a button that's responsible for say saving data, I'll give that object my transfer class and it uses the sp class and gives it this transfer class.
5. Now if a new field has to be added later, all I need to do is to modify database and regenerate these classes. The application won't change. UI needs a new control and that control needs an instance of the transfer object or a pointer to it's own variable.
Now this maybe not a good way but it's my first attempt to decouple UI classes from a form. I have some new ideas right now that I'm typing these however that might solve previous issue as well.
Thanks for the help anyway.
"In the end it's a little boy expressing himself." Yanni
|
|
|
|
|
Wow. If you are quite new to C# this is very ambitious (to say the least).
Good luck...
Regards
Thomas
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
|
|
|
|