|
What are you trying to accomplish?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I think it is called an accessor to my class but I'm not sure.
Let's say I have this
UserSettings["ITEMNAME"]
When it does this I have to Validate the ItemName and return the default if it doesn't exist. I basically want the [] to act as a property in a way. Would it be an operator?
QMuffs
|
|
|
|
|
I think C# Indexers can help you. Please check this link to know more about Indexers
Indexer In C#[^]
Software - Bundle of bugs covered with features.
|
|
|
|
|
That is it. I did it before but couldn't remember how or what it was called. I was looking everywhere. You saved me from going insane. Thank you very much.
QMuffs
|
|
|
|
|
This is a strange problem to describe so you will have to bear with me! I have developed a web application using c#.net that utilises server side ASPX pages that connect to a SQL2000 database. I have been load testing my application with the Microsoft Application Test Center that comes with Visual Studio 2003, with simulated loads of 10 - 400 users.
When I run a test against my web application for upwards of 10 concurrent users I start to get strange results from the database for what should be routine queries. I execute a simple query looking for a row in a table which I know is there (100% certain!) and the query returns the results to a dataset. I then get the first datatable from the dataset and check that the dataset.rows.count variable is greater then 0. Which it always is! I then proceed to look for a column that exists in the table which I specifically selected and an exception is thrown telling me the column doesnt exist in the datatable. This is actually impossible the data is DEFINATLEY there!
I can log into SQL Query analyser as the same SQL logon that the ASPX page uses to connect and run the same query and it returns the expected results without error or anaomoly.
Once an error of this type has occured, I can replicated it upto 10 minutes after it first has happened. During this 10 minute period I can switch the SQL logon the ASPX uses and it runs fine. As soon as I switch it back to the user on which the error occured it demonstrates the same problem again. After 10 minutes the problem disappears and wont happen again until I apply a heavy load to the server.
As an important note, I have now managed to replicate an identical problem with just 2 users trying to concurrently login.
Here is the snippet of code iam using to query the database:
public static DataSet execute_DataTable(String SQL_Command_String)
{
String connectionString;
connectionString = getConnectionString(@"..\xml_Settings\DB_Connect.xml");
makeConnection(connectionString);
DataSet dsResults = new DataSet();
try
{
SqlDataAdapter dbAdapter = new SqlDataAdapter(SQL_Command_String, dbConn);
dbAdapter.Fill(dsResults, "Results");
}
catch (Exception exp)
{
throw new Exception(exp.Message + " " + exp.StackTrace, exp);
}
finally
{
dbConn.Close();
}
return dsResults;
}
This function is located in a static class in a class library that compiles to a DLL that is then referenced in my web project. Every time an ASPX page requires to query the database this method is called.
When I load test my application a typical session will involve 2000 queries in a very short period of time. This is because I use a recursive c# function for generating a tree that executes alot of SQL queries.
Iam really out of ideas here guys , does any one have any ideas? All I can think of is disposing of the dataset when iam done?
Thanks in advance!
Mike
|
|
|
|
|
Without looking too closely, it sounds like with liberal use of the static keyword you've ended up with a whole bunch of non-thread-safe code. Have a second look at your data layer and imagine how multiple simultaneous calls will affect it.
If you are dealing with trees, try querying for the entire subtree in a single recordset to speed things up. Common Table Expressions are useful for recursively pulling out data in a single query.
|
|
|
|
|
Hey There thanks for the advice, I think I could do with reading up on thread safe code! Would it be worth while turning my Database connection code into an instanciable object and totally removing the static keywords to try and avoid these issues?
Thanks Mike
|
|
|
|
|
Hi,
I am new to C#, tried working with Validation Application blocks using the .config file approach and have run into some issues.I have created a solution file with 2 projects, 1 project has a form and am passing a value to the other project ( basically a class library )which has the app.config file and the class which contains the properties for which i have the get and set values.
Project 1
using ClassLibrary1;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
namespace Trial
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Class1 cw = new Class1();
cw.iNum = 1110;
ValidationResults results = Validation.ValidateFromConfiguration(cw, "Default");
if (!results.IsValid)
MessageBox.Show("error");
}
}
}
Project 2 has Class1.cs and the config file
Class1.cs
public class Class1
{
public int iNum;
public Class1()
{
}
#region Properties
public int Num
{
get { return iNum; }
set { iNum = value; }
}
#endregion
}
app.config
<configuration>
<configsections>
<section name="validation" type="Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.ValidationSettings, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.0.0.0, Culture=neutral" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral" />
</configsections>
<validation>
<type assemblyname="ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
name="ClassLibrary1.Class1">
<ruleset name="Default">
<properties>
<property name="Num">
<validator lowerbound="2" lowerboundtype="Inclusive" upperbound="100">
upperBoundType="Inclusive" negated="false" messageTemplate=""
messageTemplateResourceName="" messageTemplateResourceType=""
tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RangeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.0.0.0, Culture=neutral"
name="Range Validator" />
</validator></property>
</properties>
</ruleset>
</type>
</validation>
</configuration>
my problem is that i am passing a value of 1110, but the range value is from 2 till 100, yet the validation is succeeding. Am i missing out on any details
|
|
|
|
|
my app get slow when i select items in ListView because the event SelectedIndexChanged called everytime an item get select, for example if i select an item, scroll down and select another item with SHIFT after around 1000+ items then that event will be 1000+ times, i searched on google and found some solutions, like using Timer, but i want to know that is there any other good solution ?
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-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
My only suggestion to you would be to rethink your approach. Surely having 1000+ records in a list view cannot be user friendly at all...
|
|
|
|
|
so can you tell me what should i use then ??
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-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
you need to separate your ui thread from data access thread.
use the background worker class.
attach your binding logic to "progress" event in the background worker and send 10 records (adjust accordingly) at a time to the ui.
that said i kinda agree with J$
being able to filter and doing lazy loading might be a better approach. so you give more information as the user requests it.. .not just send them everything in 1 request.
|
|
|
|
|
no its not what you think, i have to give all info. to user then (s)he will select items from ListView and do some tasks...thats why List controls were created, isnt it ?
ListView is too slow in everything, like deleting, selection .... but it looks better than DataGridView
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-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
guysss
suppose i select two imagess
and i want to compare them
like if they are exactly same or not
(by selecting sum random selected rectabgular portion of the images)
then how will i compare them by pixel by pixel
or any other method
|
|
|
|
|
no, you have to compare pixel by pixel
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-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
didnt understand wat u said
|
|
|
|
|
Why do you think it is an interesting question?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Assuming they are the same file type (and assuming they are compressed the same), then why would you need to do this? Ultimately, you could just compare the two images as byte arrays. Simplistically, you could use logic similar to the following:
If the number of bytes is different, then they are different.
For loop = 0 to Length of Image1
If Image2[Loop] Does Not Match Image2[Loop] Then
The Images are different
Exit Out
End If
End If
Shout Yippee Alleluia the Images are the same
|
|
|
|
|
Pete O'Hanlon wrote: Shout Yippee Alleluia the Images are the same
That's Geordie Basic I presume?
Are you sure you're in the correct forum?
|
|
|
|
|
Read my image processing articles for examples of gaining access to images at the pixel level.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all -
I am just about finished with my first C# windows application. The only issue I have left is finding the graphics for my toolbar buttons. I was told by a friend that MSDN has a standard set of graphics. Is this true and if so were are they. I have looked everywere on MSDN for these.
Thanks!
|
|
|
|
|
In VS2005 it's installed
C:\Program Files\Microsoft Visual Studio 8\Common7\VS2005ImageLibrary
led mike
|
|
|
|
|
Hi dear fellow:
windows default toobar graphics are automatically added to the application...for this u have to select just Add Form type MDI...
Also u can use "Tool Strip" tool from the available Tools under tool boxe...just drag and drop to the top of the form..just after title bar..
ok...reply if it is helpful or needs more help...
Thanks
"Programming is a fun"
|
|
|
|
|
Can any one Help,
How to dynamically remove all data in the "Web.SiteMap" file using c# aspx 2.0.
|
|
|
|
|
Hi, i m working on a realtime video capture and i need help from a directshow veteran coder.
I need to make a directshow application with :
- Read streaming from Camera or Video file (in choice)
- Preview the capture in pictureBox
- Grab samples from SampleGrabber (to process images)
- Save the video capture in file (or not).
I need help in a simple process to activate "SAVE CAPTURE" with no interruption of the Camera or file read streaming.
See the schema here : http://etherny.no-ip.org/VKStream.gif[^]
Thx for your help.
|
|
|
|