Click here to Skip to main content
15,914,014 members
Home / Discussions / C#
   

C#

 
GeneralRe: Application localization (culture) DLLs Pin
Eli Nurman14-Jun-10 0:43
Eli Nurman14-Jun-10 0:43 
QuestionCan't add a reference to dsofile.dll [done] Pin
Ankit Rajpoot13-Jun-10 23:41
Ankit Rajpoot13-Jun-10 23:41 
QuestionLocking excel file while writing Pin
KaurGurpreet13-Jun-10 21:44
KaurGurpreet13-Jun-10 21:44 
AnswerRe: Locking excel file while writing Pin
Abhinav S13-Jun-10 21:52
Abhinav S13-Jun-10 21:52 
GeneralRe: Locking excel file while writing Pin
KaurGurpreet13-Jun-10 22:21
KaurGurpreet13-Jun-10 22:21 
AnswerRe: Locking excel file while writing Pin
Rhys Jacob13-Jun-10 23:39
Rhys Jacob13-Jun-10 23:39 
GeneralRe: Locking excel file while writing Pin
KaurGurpreet14-Jun-10 0:14
KaurGurpreet14-Jun-10 0:14 
GeneralRe: Locking excel file while writing Pin
Pete O'Hanlon14-Jun-10 0:40
mvePete O'Hanlon14-Jun-10 0:40 
GeneralRe: Locking excel file while writing Pin
KaurGurpreet14-Jun-10 20:55
KaurGurpreet14-Jun-10 20:55 
GeneralRe: Locking excel file while writing Pin
Pete O'Hanlon14-Jun-10 22:52
mvePete O'Hanlon14-Jun-10 22:52 
QuestionAODL ans .xls files Pin
SummerBulb13-Jun-10 21:34
SummerBulb13-Jun-10 21:34 
QuestionDatagridview CellValidating [Solved] Pin
jojoba201113-Jun-10 21:34
jojoba201113-Jun-10 21:34 
QuestionReport Service - passing XML paramter to filter data Pin
thenewbee13-Jun-10 21:21
thenewbee13-Jun-10 21:21 
QuestionData Passing between two different Application Pin
Priyagdpl13-Jun-10 20:06
Priyagdpl13-Jun-10 20:06 
AnswerRe: Data Passing between two different Application Pin
Md. Marufuzzaman13-Jun-10 20:31
professionalMd. Marufuzzaman13-Jun-10 20:31 
AnswerRe: Data Passing between two different Application Pin
Abhinav S13-Jun-10 21:45
Abhinav S13-Jun-10 21:45 
QuestionDo stuff while button pressed down? [solved] Pin
la0113-Jun-10 16:52
la0113-Jun-10 16:52 
AnswerRe: Do stuff while button pressed down? Pin
Luc Pattyn13-Jun-10 17:18
sitebuilderLuc Pattyn13-Jun-10 17:18 
Hi,

your label1.Invoke causes the entire while loop to execute on the main thread (so it is allowed to touch the Label), however that also blocks the thread, so your button1_MouseUp handler cannot react to the button being released. (The main thread processes its event queue, popping and executing one message at a time).

Furthermore, your while loop does not contain any timing control (such as a Thread.Sleep), so it will spin as fast as it can (depending on the characteristics and the load of your system), and clogging your Console.

I would use a very different approach, without BGW:
- have a class member of type System.Windows.Forms.Timer;
- have a class member "int tickCount";
- in button1_MouseDown clear tickCount and launch that timer, with an appropriate interval (say 100 msec), and a tick handler basically containing:
Console.WriteLine("down");
tickCount++;
label1.Text=tickCount.ToString();

- in button1_MouseUp simply stop the timer.

The advantages would be: code is much simpler, everything runs on the main thread, which is idle most of the time, as all it does is run one tick handler every 100 msec.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Nil Volentibus Arduum

GeneralRe: Do stuff while button pressed down? Pin
la0113-Jun-10 17:46
la0113-Jun-10 17:46 
GeneralRe: Do stuff while button pressed down? Pin
Luc Pattyn13-Jun-10 18:02
sitebuilderLuc Pattyn13-Jun-10 18:02 
GeneralRe: Do stuff while button pressed down? Pin
la0115-Jun-10 13:33
la0115-Jun-10 13:33 
Questionneed help Pin
aaga513-Jun-10 9:56
aaga513-Jun-10 9:56 
AnswerRe: need help Pin
Luc Pattyn13-Jun-10 10:03
sitebuilderLuc Pattyn13-Jun-10 10:03 
AnswerRe: need help Pin
Lutosław13-Jun-10 12:26
Lutosław13-Jun-10 12:26 
AnswerRe: need help Pin
Abhinav S13-Jun-10 18:18
Abhinav S13-Jun-10 18:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.