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

C#

 
GeneralRe: Service does not start Pin
Jimmanuel15-Dec-09 6:33
Jimmanuel15-Dec-09 6:33 
GeneralRe: Service does not start Pin
Jordanwb15-Dec-09 7:17
Jordanwb15-Dec-09 7:17 
QuestionPerhaps a threading problem? Pin
George Quarton14-Dec-09 10:12
George Quarton14-Dec-09 10:12 
AnswerRe: Perhaps a threading problem? Pin
Luc Pattyn14-Dec-09 11:56
sitebuilderLuc Pattyn14-Dec-09 11:56 
GeneralRe: Perhaps a threading problem? Pin
George Quarton14-Dec-09 12:17
George Quarton14-Dec-09 12:17 
GeneralRe: Perhaps a threading problem? Pin
Luc Pattyn14-Dec-09 12:41
sitebuilderLuc Pattyn14-Dec-09 12:41 
GeneralRe: Perhaps a threading problem? Pin
George Quarton14-Dec-09 12:45
George Quarton14-Dec-09 12:45 
GeneralRe: Perhaps a threading problem? [modified] Pin
Luc Pattyn14-Dec-09 13:00
sitebuilderLuc Pattyn14-Dec-09 13:00 
I would organize things a bit differently:

1) simple scheme

1A. have your PenDriveBackupForm as it is, however without the BackgroundWorker, as it does not belong to the form.

1B. have your RecursiveCopy class, with a constructor that creates a single (and private) BackgroundWorker (with the "new" keyword), to be used inside that class only; and give it a Label parameter, which you store in a private class member, so the BGW inside that class can access it.

2) better scheme (more object-oriented; keywords are: delegate, event)

2A. same as 1A.

2B. have your RecursiveCopy class, with a constructor that creates a single (and private) BackgroundWorker, to be used inside that class only; don't give it a Label parameter; give the class a public event of type Action<string> which almost means "function pointer to a function that takes a string and returns nothing". Now let your BGW fire that event.

2C. Add a "SetProgressLabel()" method to PenDriveBackupForm to accept a string and set the Label; then also add a delegate for that method to the public event you provided in RecursiveCopy.

The net result is: RecursiveCopy will execute a method of which it does not know much, and SetProgressLabel() will be called when necessary; the coupling between both classes is minimal, you can change the Label to something else without telling RecursiveCopy at all (which can't be done in the simple scheme).

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


modified on Monday, December 14, 2009 7:35 PM

QuestionTiming-related issue when connecting to a newly created database Pin
vtchris-peterson14-Dec-09 8:38
vtchris-peterson14-Dec-09 8:38 
AnswerRe: Timing-related issue when connecting to a newly created database Pin
Migounette14-Dec-09 20:44
Migounette14-Dec-09 20:44 
GeneralRe: Timing-related issue when connecting to a newly created database Pin
vtchris-peterson15-Dec-09 3:56
vtchris-peterson15-Dec-09 3:56 
QuestionC# RichTextBox strange behaviour Pin
ikurtz14-Dec-09 8:13
ikurtz14-Dec-09 8:13 
AnswerRe: C# RichTextBox strange behaviour Pin
OriginalGriff14-Dec-09 8:42
mveOriginalGriff14-Dec-09 8:42 
GeneralRe: C# RichTextBox strange behaviour Pin
ikurtz14-Dec-09 8:50
ikurtz14-Dec-09 8:50 
GeneralRe: C# RichTextBox strange behaviour Pin
OriginalGriff14-Dec-09 9:09
mveOriginalGriff14-Dec-09 9:09 
GeneralRe: C# RichTextBox strange behaviour Pin
ikurtz14-Dec-09 9:14
ikurtz14-Dec-09 9:14 
QuestionWONDER Pin
farokhian14-Dec-09 7:58
farokhian14-Dec-09 7:58 
AnswerRe: WONDER Pin
loyal ginger14-Dec-09 8:08
loyal ginger14-Dec-09 8:08 
AnswerGOLDEN WONDER Pin
Keith Barrow14-Dec-09 8:09
professionalKeith Barrow14-Dec-09 8:09 
GeneralRe: GOLDEN WONDER Pin
farokhian14-Dec-09 8:16
farokhian14-Dec-09 8:16 
AnswerRe: WONDER Pin
OriginalGriff14-Dec-09 8:39
mveOriginalGriff14-Dec-09 8:39 
GeneralRe: WONDER Pin
farokhian14-Dec-09 8:59
farokhian14-Dec-09 8:59 
GeneralRe: WONDER Pin
Luc Pattyn14-Dec-09 9:24
sitebuilderLuc Pattyn14-Dec-09 9:24 
GeneralRe: WONDER [modified] Pin
0x3c014-Dec-09 9:26
0x3c014-Dec-09 9:26 
GeneralRe: WONDER Pin
Luc Pattyn14-Dec-09 9:31
sitebuilderLuc Pattyn14-Dec-09 9:31 

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.