|
hum... good point... which brings me to the thought that there's no such thing as sparse list.
thanks
dev
|
|
|
|
|
"Any real/practical scenario?"
In an upcoming project, I have a data stream coming in, and I "clump" elements for later processing. I don't know in advance how many clumps I'm going to have, and the later processing is only going to go through them sequentially.
I'm planning on using a linked list for this.
|
|
|
|
|
hum... sequential access - why not a SortedList<int, Stream>? with key "Int" (for example DataId)
dev
|
|
|
|
|
1. A SortedList maintains an array for the elements like the generic List, so has the same disadvantages: The WHOLE list must be recopied every time it exceeds its capacity, which is slow, and which may waste space.
2. In addition, the SortedList maintains another copy of the the elements' keys for indexing, which takes even more space.
3. In my case, I don't need sorting, so this would be overhead for me, both in the time to keep it sorted, and in the extra memory required for the indexing.
|
|
|
|
|
Hi,
I have a very strange problem, i have multiple AppDomains (plugin system).
Now at one point i raise an event from one of the plugin domains and the main AppDomain catches the event and calls another function in a seperate thread that Unloads the calling AppDomain.
The first thing that came to my mind is that the plugin domain somehow became the main application domain but it didn't i checked before the culprit line below for AppDomain.FriendlyName and it was different than the main application domain.
code:
private void UnloadDevicePluginDomain(DevicePlugin d)
{
Guid id = Guid.NewGuid();
try {
lock(locker_) {
if(d == null)
return;
id = d.DevicePluginId;
if(d.PluginDomain != null) {
if(d.DeviceInterface != null) {
d.DeviceInterface.Dispose();
}
if(d.WatchDogTimer != null)
d.WatchDogTimer.Dispose();
d.PluginDomain.UnhandledException -= new UnhandledExceptionEventHandler(DevicePluginCrashed);
AppDomain.Unload(d.PluginDomain);
devicePlugins_.Remove(d);
}
}
} catch (Exception ex) {
}
}
So the weird thing is that there is an exception handler and the line nonetheless crashes the whole application.
Any help greatly appreciated.
Thanks.
-- Modified Wednesday, April 13, 2011 3:39 PM
|
|
|
|
|
I don't have an answer for ya but to save you from the pros slapping your wrist. put the code in a code block so they can read it easier.. and then they wont have to focus their answer on your code not being in a block
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
|
|
|
|
|
Hehe,
Thanks, I stand corrected and my post also...
|
|
|
|
|
Please format your code using the code block toolbar item.
Have you tried not removing the UnhandledException handler to see if the Exception is caught.
Don't know if this is useful, it's an old article
Application Suite Template[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
Thanks for your reply, i'll try removing the UhandledException unsubscription.
P.S
Sorry i didn't put the code in a code block, I know about it just forgot to use it
|
|
|
|
|
Now at one point i raise an event from one of the plugin domains and the main AppDomain catches the event and calls another function in a seperate thread that Unloads the calling AppDomain.
That sounds like the problem to me. What's probably happening is the domain is getting unloaded while its event handler is still running, and that's confusing the CLR at a level below your exception handling.
(What do you mean by 'crash', by the way?)
If you want plugins to be able to unload themselves, I think you will have to set a timer in that event handler so that the plugin domain is no longer doing stuff when you try to unload it. (And obviously, once the plugin raises that event, it should also kill any threads it spawned and not do any more processing, since it's issuing a suicide note by raising it.)
|
|
|
|
|
Hi,
That sounds like the problem to me. What's probably happening is the domain is getting unloaded while its event handler is still running, and that's confusing the CLR at a level below your exception handling.
Yes, that crossed my mind the minute the bug appeared, but the event handler adds the method to a method execution queue I designed and that queue is run in a separate thread, so the event handler 100% exits.
By crash I mean when i'm in debugging mode after i press step over over the AppDomain.Unload the debugging session ends and the application literally crashes...
The plugins do not unload themselves, a dedicated method execution queue runned by a thread that is created in the main AppDomain terminates them by processing the method I posted in the original post.
Thank you for your quick reply.
|
|
|
|
|
I'm not sure if you can unload a plugin from a different thread to the one that spawned it, come to think of it.
Running a queue in a separate thread is actually a really good way of having the unload happen before it should, unless you're applying a delay or doing some cross-domain interlocking.
I also agree with the other poster who said that you could try not unhooking the UnhandledException event handler. It should go out of scope and disappear anyway when the plugin reference is lost.
|
|
|
|
|
Hi,
After a session of debugging using all advices I collected, here are my findings (So everybody can learn from my mistakes... )
-A plugin can be unloaded from a different thread (other thread then the one that spawned it
-The problem was that I also handled UnhandledException event of the AppDomain, and a series of unfortunate events happened:
*I have 2 mechanisms for protecting my core system from plugins:
1. A watchdog timer mechanism that terminates a plugin if the plugin hasn't responded (raised an watch dog timer event) for a certain period of time
2.A UnhandledException event handler for when an unhandled error occurs in the plugin, and in that event i call UnloadPlugin function and remove the plugin from the core system
So a plugin spawned an unhandled exception the same time the watchdog timer called UnloadPlugin function... And in the UnhandledException handler it tried to use data and unload an already unloaded AppDomain
So the solution is to develop some kind of synchronization mechanism so if one request for termination comes that no other request are processed.
So the bottom line is "Threads are evil"
Thanks for your help.
|
|
|
|
|
unix_master01 wrote: // DOES NOT COME TO THIS PART
AppDomains, all of them even the main one, have an UnhandledException.
You should always set that because unhandled exceptions terminate the domain or even the application. And that is your last chance to at least try to report what the exception was.
|
|
|
|
|
Hi, when I select region combo, I can populate country combo but when I re-select region combo again, country combo append the listitem on top of the previous value. not sure why its happening. below is my code
protected void Page_Load(object sender, EventArgs e)
{
if (!(IsPostBack))
fillcombos();
ddRegion.SelectedIndexChanged +=new EventHandler(ddRegion_SelectedIndexChanged);
}
protected void ddRegion_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet ds = new DataSet();
if (ddRegion.SelectedIndex >-1)
{
ds = myBLL.GetRegionOverviewAndCountryByRegionId(Convert.ToInt32(ddRegion.SelectedValue));
DataRow dr = ds.Tables[0].Rows[0]; // get the first row returned
if (dr.ItemArray.Count() > 0)
{
txtRegionOverview.Text = dr["RegionOverview"].ToString();
ddRegion.SelectedValue = dr["RegionId"].ToString();
}
if (ds.Tables[1].Rows.Count > 0)
{
ddCountry.DataSource = ds.Tables[1].DefaultView;
ddCountry.DataTextField = "CountryName";
ddCountry.DataValueField = "CountryCode";
}
else
{
ddCountry.DataSource = null;
}
ddCountry.DataBind();
}
}
public void fillcombos()
{
List<Region> regionList = new List<Region>();
regionList = myBLL.GetRegionList();
ddRegion.DataSource = regionList;
ddRegion.DataTextField = "RegionName";
ddRegion.DataValueField = "RegionId";
ddRegion.DataBind();
}
---
<asp:DropDownList ID="ddRegion" runat="server" AutoPostBack="true"></asp:DropDownList>
asp:DropDownList ID="ddCountry" AutoPostBack="true" runat="server" ></asp:DropDownList>
in addition, I wanna it to work when i add "select a region", "select a country" at the top with
ddregion.items.insert(0,"select.."
please help
|
|
|
|
|
A couple of things:
0) Change your Page_Load method to do this:
if (!IsPostBack)
{
fillcombos();
ddRegion.SelectedIndexChanged +=new EventHandler(ddRegion_SelectedIndexChanged);
}
1) Either clear the country combo box or check IsPostBack again before adding stuff to it.
2) Your question should have been put into the ASP.Net forum.
3) Learn how to use the <PRE> tag here for code snippets.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Ok I had to clear the combo in pageload but how do I add "Please select" in this situation?
-- Modified Wednesday, April 13, 2011 9:02 AM
|
|
|
|
|
if this is in fact an asp.net application that you are just using c# for the code behind..
in the properties window look for these things
Items (collection) set the first item in that collection to "Please Select" or whatever you wish
AppendDataBoundItems set to true
ViewStateMode = false
Go to the first box and set to AutoPostBack = true.
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
|
|
|
|
|
Pls i want to create a shield to cover my screen so that
user will have to login to use the system,
i do not want to use the windows login.
thank you.
|
|
|
|
|
Enobong Adahada wrote: i do not want to use the windows login.
Why not? it does exactly what you want. If you are determined to develop your own alternative then these links[^] may help you.
|
|
|
|
|
On top of what the other poster said, that only works for Windows XP. There is no GINA in Windows Vista and above, so you'll have to create your own Credential Provider[^].
So, If you wanted to support both Windows XP and Vista and above, you'll have to write to entirely seperate projects. And you're not going to accomplish any of this in C#, at least, not as easily as you could in C++. All of the API's and SDK's, samples, and support are geared for C++.
Good Luck!
|
|
|
|
|
You can download a demo from what you want directly from Microsoft, here[^].
I are Troll
|
|
|
|
|
Place it in a safe that has a 4 digit PIN pad on the front.
"Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!"
— Hunter S. Thompson
|
|
|
|
|
hi
i face following problem in publishing the website.
Error 97 The type 'IqSiteWeb.CustomControls.DonationAgencyList' exists in both 'c:\Users\dell\AppData\Local\Temp\Temporary ASP.NET Files\iqsiteweb\5dc5d18b\b10a84ef\App_Web_jhddkwxc.dll' and 'c:\Users\dell\AppData\Local\Temp\Temporary ASP.NET Files\iqsiteweb\5dc5d18b\b10a84ef\App_Web_utdgqfe5.dll' C:\ProjectList\Kei Versions\KEI-WebSite\IqSiteWeb\Donation\DonationView.aspx 33
i tried a lot to surf the net and get the solution but i dint get any solid solution......
|
|
|
|
|
You have:
- Two dlls with the same class definition in somehow. Almost certainly the same dll twice. You'll probably will have to work out how this happened yourself.
Posted to the wrong forum: This should have been in the ASP.Net forum.- Reposted: See Mark's answer in the ASP.NET forum, his answer is the most common reason for this fault.
|
|
|
|