Click here to Skip to main content
15,895,011 members
Home / Discussions / C#
   

C#

 
GeneralRe: send file with bluetooth from pc to phone without accept Pin
DaveyM696-Sep-10 9:05
professionalDaveyM696-Sep-10 9:05 
GeneralRe: send file with bluetooth from pc to phone without accept Pin
Dave Kreskowiak6-Sep-10 17:41
mveDave Kreskowiak6-Sep-10 17:41 
AnswerRe: send file with bluetooth from pc to phone without accept Pin
allen-homen6-Sep-10 20:11
allen-homen6-Sep-10 20:11 
Questiontextbox like IE Pin
zzinbalzz6-Sep-10 6:40
zzinbalzz6-Sep-10 6:40 
AnswerRe: textbox like IE Pin
DaveyM696-Sep-10 8:24
professionalDaveyM696-Sep-10 8:24 
GeneralRe: textbox like IE Pin
allen-homen6-Sep-10 20:21
allen-homen6-Sep-10 20:21 
AnswerRe: textbox like IE Pin
V.6-Sep-10 20:25
professionalV.6-Sep-10 20:25 
QuestionDraw line in RichTextBox C# Pin
jojoba20116-Sep-10 4:55
jojoba20116-Sep-10 4:55 
AnswerRe: Draw line in RichTextBox C# Pin
Luc Pattyn6-Sep-10 5:07
sitebuilderLuc Pattyn6-Sep-10 5:07 
GeneralRe: Draw line in RichTextBox C# Pin
OriginalGriff6-Sep-10 5:33
mveOriginalGriff6-Sep-10 5:33 
GeneralRe: Draw line in RichTextBox C# Pin
Luc Pattyn6-Sep-10 5:49
sitebuilderLuc Pattyn6-Sep-10 5:49 
GeneralRe: Draw line in RichTextBox C# Pin
jojoba20116-Sep-10 5:56
jojoba20116-Sep-10 5:56 
GeneralRe: Draw line in RichTextBox C# Pin
Luc Pattyn6-Sep-10 6:06
sitebuilderLuc Pattyn6-Sep-10 6:06 
GeneralRe: Draw line in RichTextBox C# Pin
OriginalGriff6-Sep-10 5:56
mveOriginalGriff6-Sep-10 5:56 
QuestionRe: Draw line in RichTextBox C# Pin
jojoba20116-Sep-10 6:28
jojoba20116-Sep-10 6:28 
AnswerRe: Draw line in RichTextBox C# Pin
Luc Pattyn6-Sep-10 6:53
sitebuilderLuc Pattyn6-Sep-10 6:53 
GeneralRe: Draw line in RichTextBox C# Pin
DaveyM696-Sep-10 8:07
professionalDaveyM696-Sep-10 8:07 
AnswerRe: Draw line in RichTextBox C# Pin
Luc Pattyn6-Sep-10 8:19
sitebuilderLuc Pattyn6-Sep-10 8:19 
GeneralRe: Draw line in RichTextBox C# Pin
DaveyM696-Sep-10 8:27
professionalDaveyM696-Sep-10 8:27 
QuestionMulti-threading and function recursion with a form [modified] Pin
fdsfsa76f7sa66-Sep-10 3:11
fdsfsa76f7sa66-Sep-10 3:11 
AnswerRe: Mulit-threading and function recursion with a form Pin
Pete O'Hanlon6-Sep-10 3:23
mvePete O'Hanlon6-Sep-10 3:23 
GeneralRe: Mulit-threading and function recursion with a form Pin
fdsfsa76f7sa66-Sep-10 4:17
fdsfsa76f7sa66-Sep-10 4:17 
Thanks for the reply. BackgroundWorker class seems better for my situation, but I still don't really know what I'm doing. Here is what I tried as a test, but it gives me synchronization error.

public partial class Window : Form
{
    bool running = false;
    BackgroundWorker worker;
    int num = 0;
    public Window()
    {
        InitializeComponent();
        this.button.Click += new EventHandler(ButtonClick);
    }

    void ButtonClick(object sender, EventArgs e)
    {
        if (running)
        {
            // synchronization error here, I think it's
            // because there's no thread to pulse
            Monitor.Pulse(this);
        }
        else
        {
            running = true;
            worker = new BackgroundWorker();
            worker.DoWork += new DoWorkEventHandler(Work);
            // Work never executes w or w/o this:
            worker.RunWorkerAsync(); 
        }
    }

    void Work(object sender, DoWorkEventArgs w)
    {
        ++num;
        label.Text = num.ToString();
        Monitor.Wait(this);
        Work(null, null);
    }
}


Also, the function Work should have additional parameters, but this is not possible, because DoWork event requires only object and DoWorkEventArgs and nothing more. Would calling another function from function Work (and adding Wait statement to that function) work properly?

Thanks in advance!
GeneralRe: Mulit-threading and function recursion with a form Pin
Kubajzz6-Sep-10 4:31
Kubajzz6-Sep-10 4:31 
GeneralRe: Mulit-threading and function recursion with a form Pin
fdsfsa76f7sa66-Sep-10 5:13
fdsfsa76f7sa66-Sep-10 5:13 
GeneralRe: Mulit-threading and function recursion with a form Pin
Pete O'Hanlon6-Sep-10 4:59
mvePete O'Hanlon6-Sep-10 4:59 

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.