|
Honestly, I think the root of the problem is just the amount of data we have - (some constant)^n, depending on the range of values the user specifies in the data set. We would need to consider all possible combinations of values for up to 10 items, and each item can range between 0 and 25. Right now we're focusing on just 5 items, all possible combinations, which already gives us nearly 10 million combinations. Ideally, I'd rather just reduce the data set, but that's not really an option at the moment.
dybs wrote: we profiled that (the Collections DLL) as well, and ultimately most of the time was being spent in checking if a particular bucket in the Set was empty or not (for handling collision).
As for how the Set is implemented, the problem with UnionWith() is the number of times it performs the above operations.
So for each of these combinations, we call UnionWith() for each item. So with 5 items, each ranging 0-25, we potentially call UnionWith 48 million times. As mentioned above, we've reduced the number of calls significantly by caching our results as we are able to, so we only call UnionWith() for the items that have changed since the last combination we tried. We're not sure how much simpler we can make it. I'd gladly take any suggestions. Not looking for anyone to do the work for me, just general ideas on this.
Thanks,
Dybs
|
|
|
|
|
I am writing some utility code that will need to operate in both web applications and windows applications and sometimes require different behaviours (such as where to retrieve config information from).
What is the best way for code to determine whether or not it is running as part of a Web application or part of a Windows application?
|
|
|
|
|
Methinks this should do it:
bool InWebApp()
{
return (HttpContext.Current != null);
}
/ravi
|
|
|
|
|
Thanks but HttpContext seems to only be defined in the context of a web page. I'm looking to make this determination in a static class.
|
|
|
|
|
Create a property in your Utility class and use it to determine from which type of App it was called from.
None the less, you will have to set the value of thsi property from you app
|
|
|
|
|
Having done a few more experiments, I think either
AppDomain.CurrentDomain.FriendlyName.Contains("vshost.exe");
-windows app seems to have vshost.exe in that string, web apps have a guid
or
rc = AppDomain.CurrentDomain.DomainManager == null;
-windows apps have a domain manager, for web apps it seems to be null.
Guess I will go with one of these until it fails.
|
|
|
|
|
k666 wrote: AppDomain.CurrentDomain.FriendlyName.Contains("vshost.exe");
This wont work. This is due the fact that you are running you win app from visual studio.
k666 wrote: rc = AppDomain.CurrentDomain.DomainManager == null;
Even this wont work This may or may not be true depending upon the case.
Try using my previous reply.
|
|
|
|
|
Your reply essentials says set a flag from code. I would prefer that the determination be automatic and how would I ensure that the flag gets set before it is ever used?
|
|
|
|
|
The other thing you could do is to check the Uri object.
In web, it should return you the address from where it was called else I suppose it would be null or could throw an exception.
|
|
|
|
|
Uri is a class.
I don't see any static properties/routines that fit the ticket and new Uri() works fine in windows apps if I give it a valid address.
|
|
|
|
|
Hi,
I am refreshing a page every 3 min. for data update using:
this.Response.AppendHeader("Refresh", "180");
in the Page_Load event.
If no activity is detected the page should timeout forcing users to login again. The timeout is set for 20 mim. that never happens because of the 3 min refresh time.
How can I achieve both the auto refresh and timeout?
Thanks for your time
PS: this.Page.Session.Timeout - does not work???? or does it? if so how?
|
|
|
|
|
|
There is basically two solutions:
1. Get the data without reloading the page (e.g. using AJAX) from a session-less page. This of course means that the data that you get can't rely on any session variables.
2. Send some data along when you refresh the page, so that you can differentiate between the automatic refreshes and user activity. This means that you can't rely on the session timeout for the timeout. You have to handle it all yourself, keeping record of the last (non-automatic) request from the user.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
textbox.length propriety
There´s no need to create a new control, just validade with code.
If you know how to connect to a database what is your problem there?
Float, Int, Datetime i work them almost the same way, no special atention.
Do you already have done the connection to your database?
What do you have done so far?
nelsonpaixao@yahoo.com.br
|
|
|
|
|
The database connections are created using DataSets that are bound to controls to those tables and tableadapters within the dataset. Generally using a binding navigator to cycle through the records where needed.
|
|
|
|
|
I have a base form type which contains my delegate type definitions as well as standard routines that maybe used througout the application. On initialization of the base form I wire up an Update event which is triggered after I receive return data from a webservice call. The idea is to trigger the event within each running instance of the base form. I am accomplishing this now by iterating a foreach loop and firing the event seperately each time. Execution of this process can be greater than 40 seconds depending on how many forms are currently open. Is there a way of incorporating a multicast delegate to assist in triggering the events rather than the bloated foreach loop?
|
|
|
|
|
danielgmx wrote: this process can be greater than 40 seconds depending on how many forms are currently open.
danielgmx wrote: rather than the bloated foreach loop?
If I understand what you said, the root problem might be the number of forms. How many are there?
led mike
|
|
|
|
|
The form count is unknown, the forms are dynamically created from the base form via webservice response data. Here is an example of my code.
<pre>//the base form..
public delegate void SummaryDataChanged(object sender, SummaryDataChangedEventArgs e);</pre>
<pre>public virtual event SummaryDataChanged SummaryDataChangedEvent;</pre>
<pre>[STAThread()]
public ClassSpf.DataManager.ActivityReturn AnalyzeWebRequest(ClassSpf.DataManager.ActivityReturn.ActivityFlag flagType, ClassSpf.WebTargets.ProcessActivityDelegate webRequest, ClassSpf.DataManager.SpfGenericParameter genericParameter)
{
IAsyncResult iAsyncResult = webRequest.BeginInvoke(genericParameter, AnalyzeWebRequestCallBack, null);
ClassSpf.ActivityReturn activityReturn = webRequest.EndInvoke(iAsyncResult);
if (activityReturn.OutPut.Reqstatustx != string.Empty)
{
IssueMessage(activityReturn.Output);
}
if (activityReturn.ActivityException != null)
{
ClassAppTrace.HandleSystemException(activityReturn.ActivityException);
}
if (flagType == ActivityReturn.ActivityFlag.IssueUpdate)
{
if (ClassSpf.GlobalMemorySlots.Order != null && ClassSpf.GlobalMemorySlots.Operation != null)
{
this.QueueLoadSummary();
}
}
return activityReturn;
}
</pre>
<pre>
internal void QueueLoadSummary()
{
System.Threading.WaitCallback waitCallBack = new WaitCallback(LoadSummaryInformation);
System.Threading.ThreadPool.QueueUserWorkItem(waitCallBack);
}
</pre>
<pre>protected void LoadSummaryInformation(object stateInfo)
{
try
{
if (ClassSpf.GlobalMemorySlots.Input == null)
{
//well we can not load the summary data with out input now can we.
return;
}
else
{
ActivityReturn activityReturn =
WebServiceCall(ClassSpf.GlobalMemorySlots.Input, ref dataManager);
if (activityReturn.ActivityException == null)
{
if (dataManager.CurrentOrder != null & dataManager.CurrentOperation != null)
{
if (SummaryDataChangedEvent != null)
{
SummaryDataChangedEvent(this, new SummaryDataChangedEventArgs(dataManager));
}
SummaryDataChangedEventArgs summDataChanged = new SummaryDataChangedEventArgs(dataManager);
SummaryDataChangedEvent += new SummaryDataChanged(FormBase_SummaryDataChangedEvent);
SummaryDataChangedEvent(this, summDataChanged);
}
}
}
}
catch (InvalidOperationException iOx)
{
ClassAppTrace.HandleSystemException(iOx);
}
}</pre>
<pre>
FormBase_Load()
{
this.UpdateOccurredEvent += new SummaryDataChanged(FormBase_UpdateOccurredEvent);
}</pre>
//the mdiparent (inherited from base form)
<pre>private void MdiParent_SummaryDataChanged(object sender, SummaryDataChangedEventArgs e)
{
try
{
this.Invoke((MethodInvoker)delegate
{
//Some grid code goes here unimportant to the question
});
}
catch (Exception eX)
{
ClassAppTrace.HandleSystemException(eX);
}
finally
{
try
{
//Hook the event in to each child window that needs to accept it
foreach (FormBase child in this.MdiChildren)
{
(child as FormBase).OnUpdateOccurred(sender, e);
}
}
catch (Exception eX)
{
ClassAppTrace.HandleSystemException(eX);
}
}
}
</pre>
I am trying to change the foreach (FormBase child) loop to something more robust, I just don't know what now I imagine the issue is when the update is fired it is triggered by a child form thus only triggering the event for that form. I would like something like this.
Delegate UpdateType(Data Arguments);
Event UpdateType UpdateEvent;
FormBase_Load()
{
this.UpdateEvent += new UpdateEvent();
}
FormBase_TriggerChildUpdate(DataArgs e)
{
//this is where I would like to see all of the instantiated forms events fired.
//I am just not familiar enough with delegates to find a way to do so without the loop
if(UpdateEvent != null)
UpdateEvent(e);
}
|
|
|
|
|
danielgmx wrote: The form count is unknown
When it takes 40 seconds you don't know what the count is? Can't you do some debugging to find out?
led mike
|
|
|
|
|
The test case was 4 forms. I don't mean to be ignorant, but I suppose I am missing your reasoning? I will not always have 4 forms, I could have many. So delivering a count is irrelevant again unless there is something your not telling me.. Is there a limit to eventhandlers that I am not aware of?
|
|
|
|
|
danielgmx wrote: The test case was 4 forms.
Well that wasn't what I expected. I don't understand how 4 forms can take 40 seconds, that seems unreasonable, unless perhaps each form has a 1000 controls to update or something that is sucking the life out of the process. I must be missing something here because this just doesn't make sense.
led mike
|
|
|
|
|
Sounds to me like the problem is processing time within the delegate handlers, not the foreach loop which would be very quick. You could try calling each delegate asynchronously, but a better solution would probably to change how the delegate code is handled.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
You make a valid point, I appreciate your insight.
|
|
|
|
|
Hi,
I had written a webservice..which is working fine. This webservice will reside in server.
Now if I have make this webservice work for multiple servers.
Right now Iam adding a webrefernce to my application which is consuming webservice.
if this webservice has to be utilised globally..then what I have to do?
If I have to host the same webservice on different servers that leads to waste memory..since in all web methods in all the webservices have same logic and same datatype.
1.To make the same webservcie work on mutiple servers....
2. How add web refernce globally through programatically
3. If to make the webservcie work globally what are the paarameters I have to pass for them?.
4. what is best mechanism to check whether server running or down?
Kindly help me in achieving above
So kindly tell me wat is the best way..
|
|
|
|