Click here to Skip to main content
15,900,725 members
Home / Discussions / C#
   

C#

 
GeneralRe: HELP Regarding Network application Pin
amaankhan4-Nov-09 19:58
amaankhan4-Nov-09 19:58 
AnswerRe: HELP Regarding Network application Pin
amaankhan4-Nov-09 21:12
amaankhan4-Nov-09 21:12 
Question[Message Deleted] Pin
gazabdi4-Nov-09 19:31
gazabdi4-Nov-09 19:31 
AnswerRe: C# source code for converting wav file to mp3 format under Windows CE Pin
Mycroft Holmes4-Nov-09 21:35
professionalMycroft Holmes4-Nov-09 21:35 
General[Message Deleted] Pin
gazabdi4-Nov-09 22:28
gazabdi4-Nov-09 22:28 
GeneralRe: C# source code for converting wav file to mp3 format under Windows CE Pin
Richard MacCutchan4-Nov-09 23:07
mveRichard MacCutchan4-Nov-09 23:07 
GeneralRe: C# source code for converting wav file to mp3 format under Windows CE Pin
Mycroft Holmes4-Nov-09 23:38
professionalMycroft Holmes4-Nov-09 23:38 
QuestionProblem in Printing Receipt using Crystal Report using C# code Pin
sharad Pyakurel4-Nov-09 16:43
sharad Pyakurel4-Nov-09 16:43 
QuestionHelp on Key Press Event Pin
Saiyed Alam4-Nov-09 15:57
Saiyed Alam4-Nov-09 15:57 
AnswerRe: Help on Key Press Event Pin
PIEBALDconsult4-Nov-09 16:26
mvePIEBALDconsult4-Nov-09 16:26 
AnswerRe: Help on Key Press Event Pin
Calla4-Nov-09 21:47
Calla4-Nov-09 21:47 
QuestionWIA initialize object problem PinPopular
Gindi Bar Yahav4-Nov-09 11:08
Gindi Bar Yahav4-Nov-09 11:08 
AnswerRe: WIA initialize object problem Pin
Erik Rude11-Jul-10 22:11
Erik Rude11-Jul-10 22:11 
GeneralRe: WIA initialize object problem Pin
hazem00120-Jul-10 7:51
hazem00120-Jul-10 7:51 
GeneralRe: WIA initialize object problem Pin
NEspinosa23-Sep-10 14:38
NEspinosa23-Sep-10 14:38 
Questiondatetime Pin
jashimu4-Nov-09 10:15
jashimu4-Nov-09 10:15 
AnswerRe: datetime Pin
Christian Graus4-Nov-09 11:33
protectorChristian Graus4-Nov-09 11:33 
Questionneed help with adding a worker thread to my singleton Pin
abiemann4-Nov-09 9:09
abiemann4-Nov-09 9:09 
purpose
I am implementing a singleton "message queue". Several threads will enqueue messages to this queue and the worker thread will dequeue messages and process the message.

problem
in the line: "instance.threadWorker = new Thread(new ThreadStart(MessageWorker));" causes the error...
"An object reference is required for the non-static field, method, or property 'Application_Messaging.class_MessageQueue.MessageWorker()'"


code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

#pragma warning disable 0628 //suppress "new protected member declared in sealed class"

namespace Application_Messaging
{
    //singleton class because we only want one message queue
    // note: A sealed class cannot be inherited
    public sealed class class_MessageQueue
    {

        private static class_MessageQueue instance = null;
        private static readonly object padlock = new object();
        private Thread threadWorker;

        //this is a singleton, only the Instance property may be used
        protected class_MessageQueue()
        {
        }

        //property to get an instance to the class
        public static class_MessageQueue Instance
        {
            get
            {
                lock (padlock)
                {
                    if (instance==null)
                    {
                        instance = new class_MessageQueue();

                        instance.threadWorker = new Thread(new ThreadStart(MessageWorker));
                        instance.threadWorker.Start();
                    }
                    return instance;
                }
            }
        }

        private void MessageWorker()
        {
            //will be a loop to dequeue messages
        }


    }//end of: class class_MessageQueue

}//end of: namespace



how can I get the worker thread running ?
AnswerRe: need help with adding a worker thread to my singleton Pin
PIEBALDconsult4-Nov-09 9:13
mvePIEBALDconsult4-Nov-09 9:13 
GeneralRe: need help with adding a worker thread to my singleton Pin
abiemann4-Nov-09 12:51
abiemann4-Nov-09 12:51 
GeneralRe: need help with adding a worker thread to my singleton Pin
PIEBALDconsult4-Nov-09 14:05
mvePIEBALDconsult4-Nov-09 14:05 
AnswerRe: need help with adding a worker thread to my singleton Pin
Luc Pattyn4-Nov-09 9:39
sitebuilderLuc Pattyn4-Nov-09 9:39 
GeneralRe: need help with adding a worker thread to my singleton Pin
PIEBALDconsult4-Nov-09 10:56
mvePIEBALDconsult4-Nov-09 10:56 
GeneralRe: need help with adding a worker thread to my singleton Pin
Luc Pattyn4-Nov-09 11:08
sitebuilderLuc Pattyn4-Nov-09 11:08 
GeneralRe: need help with adding a worker thread to my singleton Pin
abiemann4-Nov-09 12:42
abiemann4-Nov-09 12:42 

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.