|
If an instance of an object subscribes to a static event, even if the instance goes out of scope it remains 'alive' which could potentially cause serious memory problems.
Obviously, the subscriber unregistering itself from the delegate's invocation list solves this, but is there anyway to do this from the class with the event rather than relying on the subscriber over which we may not have control (if we're not writing that code)?
I rarely use static events, this is more out of academic interest.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Maybe if you override the add of the static event and use a weak reference to store the delegate?
If that's even possible
|
|
|
|
|
I've just found a great article[^] on weak events. Some after dinner study there.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Nice, much better suggestions than mine
|
|
|
|
|
Lol, not at all - you pointed me in the right direction.
This other article[^] is also interesting!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Wow that took a while to read
This problem sure is a lot more complicated than I originally thought
|
|
|
|
|
Dave,
See here[^]. Jon Skeet has taken it neatly.
|
|
|
|
|
I need to have a databinding of List<book> or anything ..
I have SQL SErver and a functions which returns List<book> from Database..
Now if I am doing like this:
BindingSource src = new BindingSource();
src.DataSource = Book.GetList(); //A Getlist function from Book class returning the list<book> object.
datagridview1.DataSource = src;
Everything works fine..
But if I need to filter the bindingsource , I know we have a filter property like this.
src.Filter = "Author = " + anything.ToString();
But this is not working...
But if I am having a DataSource of DataTable having a table of Book . .
ie. . if I write..
src.DAtaSource = Book.GetTable();
Everything goes fine .. But on List it doesnt work properly . .
Can anyone help me out ???
|
|
|
|
|
I'm just getting into the List stuff as well, looks like you need to write your own filtering methods. Look into List<t>.FindAll.
I'm still to be convinced a List<> is better than a datatable/view for this stuff. Ah well research, it's what keeps us interested!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes It's preety fine to work with list. .
As it can be handled very easily. And also It can be easily used in 3 tier architecture.
Regarding the filtering of list , Actually list can be filtered using LINQ.
It can be done something like this;
var result = from p in lststudents
where p.FirstName = 'Jay'
select p;
This works fine. But I am more precisely talking about the filtering of Binding source.
It works with datatable , but not with List..
Anyway thanx for your concern. .
|
|
|
|
|
Hi,
not sure this is the place for the question as this is an architecture question, but i'm programming in c# so i came here.
My question involved a problem that I'm guessing a lot of programmers face at some point , My boss wants to send an email to a mailing list, that’s easy,
The mailing lists though should be created by the clients using the back office,
Not by picking users from the database, but by specific parameters, say
if the user is older than 18, or if the user order is from this or that store, basically almost any field in the database can be part of the mailing list criteria,
Question is:
how to display the parameters in the back office so the client which is a computer novice will be able to understand what he is doing
how to save the query in the database(which will probably include some joins and what not
Or maybe some other general idea on how to solve this problem
Thanks in advance
|
|
|
|
|
Hi, I am working on a task scheduler. Apart from scheduling tasks, daily, weekly, etc .. I would also like to let them run at login, but more importantly before the system shuts down.
I tried several methods already:
(1) by trying to intercept the shutdown and starting the application. At the moment it works but sadly the writer of this example code mentioned himself that it's not that trustworthy. It doesn't always work. So that’s not the best solution.
private void PreventShutdown()
{
SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);
}
private void SystemEvents_SessionEnding(Object sender, SessionEndingEventArgs args)
{
if (args.Reason == SessionEndReasons.SystemShutdown)
{
args.Cancel = true;
}
}
(2) by using the group policy settings, and placing a script file (task.bat) in the "windows\system32\grouppolicy\machines\scripts\schutdown" folder + a scripts.ini in the ... scripts folder. (apparently you can't access these GP, scripts settings programmatically)
If you do this manually (gpedit.msc) it works, but if you generate the files in code and place them in the appropriate folders it doesn't.
Can anyone help me with this problem. Is there anyone that has some experience with this, knows other ways to achieve my goal or maybe tell me what I'm doing wrong ?
Any help/suggestions much appreciated.
Thanx
modified on Sunday, March 8, 2009 8:57 PM
|
|
|
|
|
after some more googlin and reading thru msdn, I found the settings of the group policy scripts in the registry.
So I tried it like that; creating the right keys and values in code.
the tasks pop up in gpedit, scripts, shutdown ...
Every setting looks the same as when I would do it manualy with gpedit. Still when I shutdown the system, no batch file is being run. (the batch file itself works fine)
Is there nobody on this forum that has some experiance with this kinda stuff ?
thanx
|
|
|
|
|
Hello
I'm trying tu use mouse event (move, click) to select elements on a page on a printpreview control
But HOW can I get the page location relative to the princontrol Bound ?
Thank you very much for any help
|
|
|
|
|
hi
i used a Microsoft.Office.Interop.Owc11.ChartSpace object
it works and draw me a nice chart but when i use following code
if (ChartSpace.Charts.Count != 0)
ChartSpace.ExportPicture("C:\\abc.jpg", "Jpg", 640, 400);
it will be rise an exception "Unknown error."
with error code : -2147467259
what would i do?
thanks in advance.
|
|
|
|
|
i have com component which i converted to dll using tblimp tool. I am able to add reference of the dll to my code but when i call the function of the dll i get an error message saying "cannot find entry point"
could any one help me out in solving these issues.
|
|
|
|
|
It is very important to me to convert the webpage to images
pls help me out
I shall be grateful to you
|
|
|
|
|
http://www.codeproject.com/KB/graphics/IECapture.aspx[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
how it can be encrypted..............
if you can't put it here pls mail me
@ vinod8812@gmai.com
|
|
|
|
|
Hi all,
i just download a itextsharp.dll
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using _____.itextsharp; <-- What should i put at this line ?
For PDF Converter & Image Converter
Thank you
modified on Sunday, March 8, 2009 4:11 AM
|
|
|
|
|
|
How do I invoke external windows applications (AutoCAD) through C#.Net code?
Zaki
|
|
|
|
|
|
My english is poor,so if i misunderstood your question please do not make fun of me.
System.Diagnostics.Process.Start(String filePath);
the parameter filePath you can read form the regedit;
|
|
|
|
|
How do cut data from datagrideview ?
|
|
|
|