|
Hi Guys,
I'm trying to get my forms to clean up after themselves when i dispose them. The designer builds all the lovely disposal pattern stuff, with the body:
<br />
if (disposing && (components != null))<br />
{<br />
components.Dispose();<br />
}<br />
base.Dispose(disposing);<br />
Which is all well and good, but as i add components to the designer, i would assume they would be placed in a container and cleaned up when the form disposes, however, the container is always null, and hence the dispose is never called.
Because of this my background worker keeps running and my underlying win32 api calls are never closed down.
While i can (and will) do this the manual way, is there any way to have the designer wire up that logic for me?
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
If this is a Windows Forms application and you are adding the components using the designer the necessary code for disposing them is generated automatically, or at least should be.
As far as a background worker is concerned, it is working in the background, in a different thread, and that will continue to run. Try handling the FormClosing event and stop the background worker there.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: or at least should be.
Yeah, i thought the same, but it's clearly not doing any finalizing or disposing when i close the form. The app is quite complicated, a lot of components being shared between multiple forms, but some of the forms contain components only applicable in that scope, and the form gets re-used, so i don't want to do cleanup on close, but only on dispose which occurs when the app gets dismantled.
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Ah.
I'm not sure of what happens in Dispose() when the control/component is referenced elsewhere.
You could try handling Application.ApplicationExit maybe?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I've got the Close event handled in the application host form, and it disposes the primary application container, but i was hoping it would tidy up the various components in the nested containers / forms.
(And thinking about this gives me a headache...)
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Sounds like you need to consider using a WeakReference or two.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
[Edit] - Never mind, i didn't realize that WeakReference was a class. I thought it was just the opposite of tight coupling. :P
Now... coffee...
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Actually multiplication of MemberCount and Commission Should be done and result should get displayed in MemberGrandTotal when we hit Show button....and as the registration forms get filled by the customer automatically the values in MemberCount should be increased and as per that result should get displayed...Also the values in MemberCount should remain same to values in Distributor..It should not exceed the count.
My code is as below...
String s = "Data Source=.\\sqlexpress;Initial Catalog=MLM;Integrated Security=True";
SqlConnection con = new SqlConnection(s);
con.Open();
DataSet ds = new DataSet();
int Level=1;
foreach (DataRow dr in ds.Tables[Level].Rows)
{
String s1="Select MemberCount,Commission,MemberCount*Commission from LevelCount ";
}
//DataSet ds = new DataSet();
SqlCommand com = new SqlCommand(s1, con);
SqlDataReader rs = com.ExecuteReader();
while (rs.Read())
{
Label10.Text = rs.GetInt32(0).ToString();
Label9.Text = rs.GetInt32(2).ToString();
Label11.Text = rs.GetInt32(0).ToString();
Label12.Text = rs.GetInt32(0).ToString();
Label13.Text = rs.GetInt32(0).ToString();
Label14.Text = rs.GetInt32(0).ToString();
Label15.Text = rs.GetInt32(0).ToString();
Label16.Text = rs.GetInt32(2).ToString();
Label17.Text = rs.GetInt32(2).ToString();
Label18.Text = rs.GetInt32(2).ToString();
Label19.Text = rs.GetInt32(2).ToString();
Label20.Text = rs.GetInt32(2).ToString();
}
//rs[5] = s;
com.ExecuteNonQuery();
//rs.Close();
con.Close();
and table is as follows....
Level Distributors MemberCount Commission GrandTotal MemberGrandTotal
1 5 5 25
2 25 10 250
3 125 10 1250
4 625 10 6250
5 3125 10 31250
6 15625 15 234375
Show
Thanks in advance......
|
|
|
|
|
I am afraid that the code you have posted is so badly broken, that I am at a loss to know how to help you.
Also your explanation of your problem is not sufficiently clear to enable me to attempt an answer.
Please try to rephrase your question, so that someone who is not familiar with your application, can understand what it is that you require.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
multiplication of columns MemberCount and Commission upto Levels 1 to 6 is to be done and result should be displayed into the column MemberGrandTotal
|
|
|
|
|
Hi Sir
I am new for .net.I'm Creating Student mark list program.
I have one doubt in sql.
for every sql operation i am opening sql connection after i'm closing the connection.
is this wright?due to this any problem will come?
|
|
|
|
|
The answer to this one is "It depends". Is your application a desktop application running a local database instance? If so, it may be acceptable to open up a connection and leave it open for the duration of your processing (with appropriate code in place to take care of database crashes). Is this running on an ASP.NET application? If so, you MUST release the connection as soon as practically possible.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Dear Sir
I'm Using .net windows application & local instance only.
I'n my project i did't write code for closing the database,it is always open only.
What is My problem is Yesterday i asked my Crystal report view (first time) taking long time.
U replayed "//
If your database connection has not been pooled, then the first preview will take a lot longer than the second time where it's pulled from the pool.//" like this .thats y i'm asking i want to close or not(my database connection)
|
|
|
|
|
Again - this is up to you. Basically, when you open up a connection the first time, this takes quite a while - if you open it again and it's in a connection pool, the connection is taken from the pool (assuming you supply the same credentials). If you leave the connection open, then the first time it will take a while, but the next time it will be a lot faster because you won't have the overhead of opening the connection.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Once again thnx for ur Replay Sir.
Sir
Crystal report Preview i want fast,For that tell any one simple way.
I'm Not too intelligent please solve my problem.
|
|
|
|
|
The data is not getting inserted into the database...
i have written the following code...
SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=MLM;Integrated Security=True");
con.Open();
SqlCommand com = new SqlCommand("Insert into RegistrationForm(UserName,Pin_ID,SponserName,Sponser_Pin,Registration_Date,Main_Sponser_Name,Placement_Info,Title,Maritial_status,MemberName,CompanyName,Date_Of_Birth,Age_In_Years,Mother_Name,Address,City,State,PinCode,Phone_No,Mobile_No,Email_Id,Pan_No,Nominee_Name,Relation_with_member,Nominee_Birth_Date,Age,DD_No,Bank_Name,Branch_Name,Enter_Login_Password,Confirm_Login_Password,Enter_Pin_Password,Confirm_Pin_Password)values('" + TextBox30.Text + "','" + TextBox31.Text + "','" + TextBox26.Text + "','" + TextBox27.Text + "','" + TextBox28.Text + "','" + TextBox29.Text + "','" + RadioButtonList1.Text + "','" + DropDownList4.Text + "','" + DropDownList6.Text + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox3.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + DropDownList5.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "','" + TextBox13.Text + "','" + TextBox14.Text + "','" + TextBox15.Text + "'," + TextBox16.Text + "," + TextBox17.Text + ",'" + TextBox18.Text + "','" + TextBox19.Text + "','" + TextBox20.Text + "','" + TextBox21.Text + "','" + TextBox22.Text + "','" + TextBox23.Text + "','" + TextBox24.Text + "')", con);
string s1 = TextBox30.Text;
string s2 = TextBox28.Text;
string s3 = TextBox1.Text;
string s4 = TextBox7.Text;
string s5 = TextBox8.Text;
string s6 = DropDownList5.Text;
string s7 = TextBox9.Text;
string s8 = TextBox27.Text;
string s9 = TextBox26.Text;
Response.Redirect("Welcomeltr.aspx?TextBox30=" + s1 + " &TextBox28=" + s2 + "&TextBox1=" + s3 + "&TextBox7=" + s4 + "&TextBox8=" + s5 + "&DropDownList5=" + s6 + "&TextBox9=" + s7 + "&TextBox27=" + s8 + "&TextBox26=" + s9);
com.ExecuteNonQuery();
//com2.ExecuteNonQuery();
con.Close();
Thanks in advance
|
|
|
|
|
Several things come to mind looking at your code.
1. This isn't the ASP.NET forum.
2. Your variable naming convention sucks. TextBox28? TextBox29? What do they mean? Please - give variables a more meaningful name.
3. Your code is wide open to SQL Injection attacks.
4. You do a redirect before you ever attempt the execute on the SQL.
5. Your redirect is using unencode URL entries - what happens, for instance, if TextBox30 is "Hello there'.!***"?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I have dictionary of x and y cordinates and with this cordinate i have drawn a polygon.After drawing the ploygon it is now combination of Lines And Curves.
Can any one guide me how to segregate points of dictionary that I can understand these points are for Line and those points are for Curves.
with regards
tarak
|
|
|
|
|
I'm not sure I understand the problem.
Surely, if you're drawing the lines and curves you know which points you've used for each, and can save that information.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
hiii
molesworth
The drawing of polygon is in very later stage.
My aim is by visualizing the neighbouring point how can i under stand these set of points will be in straight line and those set of points will be in curve????
|
|
|
|
|
Ah, I think I understand. You want to draw a line when the points are on a line (or close to it) and a curve of some sort otherwise.
The simplest way that comes to mind is to calculate the slope of the line segments between pairs of points and if all the slopes are equal (within some reasonable limits) then the points lie on a straight line.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
hi
molesworth
thanx for reply.
|
|
|
|
|
hi
molesworth
thanx for reply
But there may be lots of line in various direction..in that case how the slope is same for every line??
|
|
|
|
|
It seems I've misunderstood your problem. I was guessing from the description that you had a number of points (x,y) and wanted to draw lines through them. If the points lie on a straight line, then you want to draw only that straight line through them, but if they don't then you want to draw a curve through them.
Perhaps you can explain with a bit more detail what you are trying to do.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Mr.molesworth
thanx for reply
yes u are right that i have number of points(x,y) near about 1000.If i plot all these points in graph paper then it looks like a polygon.And polygon is combination of lots of curve and lines. And in curve there are lot of combination of small length of straight line.Basicaly if i join two point it becomes straight line.
And in curve the each small straight lines bend very slightly and it appears in graph like a curve. But i dont want to plot these point on the graph paper.
Only i have set of points(x,y).
How can i calculate that some set of points will be used for drawing one or more than one curve and other set of points will be used for drawing the line or lines..
awaiting for ur reply....
|
|
|
|
|