Click here to Skip to main content
15,913,836 members
Home / Discussions / C#
   

C#

 
GeneralRe: Passing TextWriter through a function Pin
Mirko198031-Mar-10 3:00
Mirko198031-Mar-10 3:00 
AnswerRe: Passing TextWriter through a function Pin
R. Giskard Reventlov31-Mar-10 2:45
R. Giskard Reventlov31-Mar-10 2:45 
GeneralRe: Passing TextWriter through a function Pin
Luc Pattyn31-Mar-10 2:54
sitebuilderLuc Pattyn31-Mar-10 2:54 
GeneralRe: Passing TextWriter through a function Pin
R. Giskard Reventlov31-Mar-10 2:59
R. Giskard Reventlov31-Mar-10 2:59 
AnswerRe: Passing TextWriter through a function Pin
Steve-Co31-Mar-10 2:56
Steve-Co31-Mar-10 2:56 
QuestionSafe thread calls Pin
faheemnadeem31-Mar-10 1:41
faheemnadeem31-Mar-10 1:41 
AnswerRe: Safe thread calls Pin
Luc Pattyn31-Mar-10 1:52
sitebuilderLuc Pattyn31-Mar-10 1:52 
GeneralRe: Safe thread calls Pin
faheemnadeem31-Mar-10 2:04
faheemnadeem31-Mar-10 2:04 
I understand your point clearly... this code is a part of a windows service... Please find the code below.
This is the serial data received event(part of a running windows service).
Where i just called a static event and passing in some event arguments (custom made)
private void serialCnn_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                
                // Send received data to data processor for parsing and filtering
                EventReporter.SendData(new SendSerialDataArguments
                {
                    SerialPortName = ((SerialPort)sender).PortName,
                    Source = Entity.SerialServer,
                    Destination = Entity.DataProcessor,
                    SourceServer = Entity.SerialServer,
                    TransmittedDataType = TransmittedDataType.RawProcessed,
                    Data = new Message(((SerialPort)sender).ReadTo("\r"))
                });
                /*
                msq.Send("pinki", MessageQueueTransactionType.Single);
                msq.Close();
                msq.Dispose();
                */
            }
            catch (Exception ex)
            {
                // Report error to event log
                this.MiscFunctions.WriteToLog(Entity.SerialServer, ex);
            }
        }



The method called is a static method in a class library reference by this windows service.
The method is:
public static void SendData(SendSerialDataArguments args)
 {
     try
     {
         // Add message formatter property
         args.Data.Formatter = new BinaryMessageFormatter();

         // Add a label to message
         args.Data.Label = ((int)args.Source).ToString() + ":" + ((int)args.Destination).ToString()
             + ":" + ((int)TransmittedMessageType.Data).ToString() + ":" + ((int)args.SourceServer).ToString()
             + ":" + ((int)args.TransmittedDataType).ToString() + ":" + args.SerialPortName;

         // Enable message to persist to disk rather than memory
         args.Data.Recoverable = true;

         // Check destination for message, choose queue accordingly
         switch (args.Destination)
         {
             case Entity.Application:
                 {
                     // Send message with custom label and current transaction reference
                     msgQPL.Send(args.Data, MessageQueueTransactionType.Single);
                 }
                 break;

             case Entity.DataProcessor:
                 {
                     // Send message with custom label and current transaction reference
                     msgQCL.Send(args.Data, MessageQueueTransactionType.Single);
                 }
                 break;
         }
     }
     catch (Exception ex)
     {
         // Write exception to event log
         MiscFunctions.WriteToLog(Entity.EventReporter, ex);
     }
 }


The msgqueue objects msgqcl and msgqpl are also static and defined elsewhere in the same class as static.
I even changed the method to not a static one and disposed msq object in it but same result.
any further help!!!
GeneralRe: Safe thread calls Pin
Luc Pattyn31-Mar-10 2:26
sitebuilderLuc Pattyn31-Mar-10 2:26 
GeneralRe: Safe thread calls Pin
faheemnadeem31-Mar-10 2:39
faheemnadeem31-Mar-10 2:39 
AnswerRe: Safe thread calls Pin
Alan N31-Mar-10 3:02
Alan N31-Mar-10 3:02 
GeneralRe: Safe thread calls Pin
faheemnadeem31-Mar-10 3:24
faheemnadeem31-Mar-10 3:24 
AnswerRe: Safe thread calls Pin
faheemnadeem31-Mar-10 21:18
faheemnadeem31-Mar-10 21:18 
QuestionOutof memory exception creating a thumbnail Pin
Mycroft Holmes31-Mar-10 1:21
professionalMycroft Holmes31-Mar-10 1:21 
AnswerRe: Outof memory exception creating a thumbnail Pin
Luc Pattyn31-Mar-10 1:58
sitebuilderLuc Pattyn31-Mar-10 1:58 
GeneralRe: Outof memory exception creating a thumbnail Pin
Bernhard Hiller31-Mar-10 2:19
Bernhard Hiller31-Mar-10 2:19 
GeneralRe: Outof memory exception creating a thumbnail Pin
Luc Pattyn31-Mar-10 2:28
sitebuilderLuc Pattyn31-Mar-10 2:28 
GeneralRe: Outof memory exception creating a thumbnail Pin
Mycroft Holmes31-Mar-10 12:09
professionalMycroft Holmes31-Mar-10 12:09 
GeneralRe: Outof memory exception creating a thumbnail Pin
Luc Pattyn31-Mar-10 12:29
sitebuilderLuc Pattyn31-Mar-10 12:29 
GeneralRe: Outof memory exception creating a thumbnail Pin
Mycroft Holmes31-Mar-10 12:58
professionalMycroft Holmes31-Mar-10 12:58 
QuestionPointToScreen and multiple monitors Pin
vlasto7731-Mar-10 1:18
vlasto7731-Mar-10 1:18 
AnswerRe: PointToScreen and multiple monitors Pin
V.31-Mar-10 3:03
professionalV.31-Mar-10 3:03 
GeneralRe: PointToScreen and multiple monitors Pin
vlasto7731-Mar-10 3:14
vlasto7731-Mar-10 3:14 
GeneralRe: PointToScreen and multiple monitors Pin
V.31-Mar-10 3:26
professionalV.31-Mar-10 3:26 
QuestionHow to Save/Store non serializable objects Pin
Anindya Chatterjee31-Mar-10 1:06
Anindya Chatterjee31-Mar-10 1:06 

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.