|
yeah that crossed my mind too. but it seems a bit sadistic to me anyways.
funny thing is i knew about Application.DoEvents() and actualy used it .. but to no result. in my test i placed it in the while loop because normaly you want from time to time the app to respond to other calls but oddly it didn't work(no idea why thow).
the other thing that crossed my mind was to add a messageFilter before thread.Start and remove it after my task finished. but that's a bit too costly in my opinion.
|
|
|
|
|
put this as a class variable
<br />
private ThreadStart ts= new ThreadStart(urfunctionhere);<br />
private Thread t=new Thread(ts);<br />
then in ur button u could do
{<br />
<br />
button.enabled=false;<br />
<br />
if(t!=null&&!(t.isAlive))
{<br />
t.start(); <br />
}<br />
<br />
button.enabled=true;<br />
<br />
}
hope this help u
|
|
|
|
|
well for one your example doesn't work. mainly because that's not the propper way to test if a thread is running. however even if i correct that problem it still doesn't solve my problem because now you have to sincronize the started thread. if you will read my third post you'll see a sincronised example that well you guessed it .. doesn't stop the calls.
|
|
|
|
|
You may try the following method if it works (it apparently works on my machine; however I cannot test in your conditions).
As an event can be handled by more than one event handler, you may declare two event handlers for the same button click by using two different methods, as under:
this.button1.Click += new System.EventHandler(this.button1_Click);
this.button1.Click += new System.EventHandler(this.button1_Click2);
It is pertinent to mention here that when an event is handled by more than one handler, all the methods handling that event are executed. The order in which the methods execute is the same as the order in which the association was created. Thus, in this case, "button1_Click" method will be executed first and thereafter the second method "button1_Click2" will be executed. What I suggest it that you disable the button1 in the first such method and do your long task in the second method. As by the time the second method starts, the first method must already have been executed (meaning that the button1 is now already disabled), you can safely do your long task in the second method. The code can be something like this:
private void button1_Click(object sender, System.EventArgs e)
{
this.button1.Enabled = false;
}
private void button1_Click2(object sender, System.EventArgs e)
{
this.button1.Enabled = true;
}
I am not sure, but I hope that your problem can be solved in this manner.
|
|
|
|
|
Hi all,
one big disadvantage (that's my feeling) of .Net-App is, the application startup delay on the first start (loading libraries etc.). I am going to write a "Do nothing Apps" which will be loaded on autostart, so that the libraries are in memory an the other applications will start faster.
.... or is there a much better way to improve the startingtime ?
Frank
|
|
|
|
|
That might work, until you load something that the OS decides is more important and frees up the unused, but still cached, libraries.
I guess I wouldn't bother. All you're doing is moving the problem around. Now you're computer will boot that much slower! And you still won't have solved your "first time load" time delay.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
I have a new lunatic idea,
I write a VB6 app's, showing a pretty logo and the hourglass cursor, do a process-start of my .net app's and make a challange to the user to cook e new coffee, make two or three phone calls and than...... my app's still ready to work.
.... o.k we are in the Einstein Year - time is relative - if we move slower ... time goes faster or something like that.
That's another day of microsoft frustation.
Frank
|
|
|
|
|
Don't do it.
If you send the loading time to system startup, you will make it slower every time; and it's not every time that your users turn on their computer to use your app, is it?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
|
hi,
i use asqldatareader to read my data which the commandtext
has two transaction inside,when i attempt to get the data by Read() method it gets the first result set and the other is lost,when i use NextResult() method i get the other result set but first result of the set is skipped,
what should i do?
here is my commandtext:
mycommand.CommandText="SELECT COUNT(TypeId) FROM mytable1; SELECT Name, TypeId FROM mytable2 ";
|
|
|
|
|
|
hi,
here is my code:
com.CommandText="SELECT COUNT(TypeId) AS idcount "<br />
+"FROM NewsTypes ; SELECT Name, TypeId FROM NewsTypes "<br />
+"ORDER BY TypeId";<br />
try<br />
{<br />
SqlDataReader rd=com.ExecuteReader();<br />
rd.Read();<br />
temp=new NewsTypes[(int)rd["idcount"]];<br />
int index=0;<br />
while(rd.NextResult())<br />
{<br />
rd.Read();<br />
temp[index]=new NewsTypes((string)rd["name"],(short)rd["typeid"]);<br />
index++;<br />
}
thanks
|
|
|
|
|
Hi UAU,
The problem is with your while statement. Instead of that use a do while loop while using the NextResult on datareader. Guess the following code will help you.
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "";
conn.Open();
SqlCommand percommand = new SqlCommand("select * from person;select count(*)as name from person;",conn);
SqlDataReader reader = percommand.ExecuteReader();
do
{
while(reader.Read())
{
MessageBox.Show(reader["name"].ToString());
}
}while(reader.NextResult());
Thanks and Regards
SGS
|
|
|
|
|
|
unfortunatley this doesnt work yet,i lost first row of
the next resultset,i examined several ways but i loose my rows
|
|
|
|
|
|
I did so but i lost the first row of resultset.
I think i'd better use dataset instead.
|
|
|
|
|
My windows application creates word documents from template document with bookmarks and data from database. I create one document for each user, e.g. I select five users and application creates five MS word documents filled by data from database. Documents are saved in memory. I use reference to "Microsoft Word 9.0 Object Library" (MS Word 2000). My target is application creates word documents and merges into one document and saves it. Can you help me?
|
|
|
|
|
Have a look here[^].
It's a Web-based solution but it's quite similar to what you are after, and can easily be ported to a Windows application.
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Hi Guys,
I have a problem though I think it's hard to solve this unless you see the codes. Allow me to share to you and if you have any ideas that can help or comments is most welcome.
I have a tracking system web based program that record a daily activity of a certain operation department. Most of the time 2 or more users are working at the same time from different building. What I',m doing since it's a header/ detail information everytime they create new record and fill up the detail part I saved the record straight to our SQL database using a temporary key then when the USER PRESS a SEND BUTTON what I do is update the TEMP KEY with the original key of a record. The problem is that IF two users do this at the same time sometimes I get the other information record so when I open the file the next time for checking there is inconsistency of record because I can see that the information on the screen is supposed to be in the other person. If two page are open at the same time SOMETIMES I saved the page information which is wrong.
I don't used GLOBAL variable, all are local. Any Ideas?
Thanks
/dabuskol
|
|
|
|
|
I think you should consider reviewing your Database structure rather than your application's architecture. A good way for handling concurrent multi-usability would be to provide locks on the tables you are using (e.g. pessimistic/optimistic record or table locks, etc.).
I haven't done this before on SQL Server but I am 101% sure there are ways to handle multiple users.
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Hi,
Can someone help me to pass parameters from C# to a .au3 file (with a sample preferably).
Regards,
Abi
|
|
|
|
|
How to merge / include / embed an image file (such as jpg, wmf, etc.) in an Assembly so that the image file is also compiled inside the Assembly executable itself, instead of keeping the same as an outside file.
Keeping an image file outside the Assembly requires the presence of the image file alongwith the executable, causing error if the user has by mistake deleted the image file.
|
|
|
|
|
Have a look here[^].
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Hi,
1) Create a resource file using ResEditor.
2) Using AddExistingItem option of the project add the resource file to the project and Build the application.
3) Use the ResourceManager class to retrieve these resources (use getstring and GetObject methods).
Thanks and Regards
SGS
|
|
|
|