473,320 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need help ASAP.....Messagebox problems.

I have a messagebox that I only want to pop up only if it is not already
being displayed on the screen.

My code is still poping up the messagebox even though it is on the screen.
What am I doing wrong here. Any suggestions on how to fix this
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Web;
using System.Windows.Forms;

using EventListenerOCS;

namespace EventListener
{
/// <Summary> Summary description for SocketListener.</Summary>
public class SocketListener
{
/// <Remarks> Variables that are accessed by other classes
indirectly.</Remarks>
private Socket m_clientSocket = null;
private bool m_stopClient=false;
private Thread m_clientListenerThread=null;
private bool m_markedForDeletion=false;
private bool IsDisplayed=true;

/// <Summary>Client Socket Listener Constructor.</Summary>
/// <param name="clientSocket"></param>
public SocketListener(Socket clientSocket)
{
m_clientSocket = clientSocket;
}

/// <Summary> Client SocketListener Destructor.</Summary>
~SocketListener()
{
StopSocketListener();
}

/// <Summary> Method that starts SocketListener Thread.</Summary>
public void StartSocketListener()
{
if (m_clientSocket!= null)
{
m_clientListenerThread =
new Thread(new ThreadStart(SocketListenerThreadStart));

m_clientListenerThread.Start();
}
}

/// <Summary> Thread method that does the communication to the
client.</Summary>
/// <Remarks> This thread tries to receive data from client.</remarks>
private void SocketListenerThreadStart()
{
int size=0;
Byte [] byteBuffer = new Byte[1024];

while (!m_stopClient)
{
try
{
size = m_clientSocket.Receive(byteBuffer);
ReceiveData(byteBuffer, size);
}
catch (SocketException se)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"Socket Error #" + se.ErrorCode + ":: " + se.Message);

m_stopClient=true;
m_markedForDeletion=true;
}
}
}

/// <Summary> Method that stops Client SocketListening
Thread.</Summary>
public void StopSocketListener()
{
if (m_clientSocket!= null)
{
m_stopClient=true;
m_clientSocket.Close();

/// <Remarks>Wait for one second for the the thread to
stop.</Remarks>
m_clientListenerThread.Join(1000);

/// <Remarks> If still alive; Get rid of the thread.</Remarks>
if (m_clientListenerThread.IsAlive)
{
m_clientListenerThread.Abort();
}
m_clientListenerThread=null;
m_clientSocket=null;
m_markedForDeletion=true;
}
}

/// <Summary> Method that returns the state of this object</Summary>
/// <Remarks> i.e. whether this object is marked for deletion or
not.<Remarks>
/// <returns></returns>
public bool IsMarkedForDeletion()
{
return m_markedForDeletion;
}
/// <Summary> This method checks to see if the messagebox is displayed
/// on the XXX already.</Summary>
/// <param name="byteBuffer"></param>
/// <param name="size"></param>
///
private void MsgBxDisplayed(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);
// bool IsDisplayed = false;
try
{

if (IsDisplayed == false)
{

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);
// Displays the MessageBox.

MessageBox.Show(" Disk Failure. Call xxxxxx", "WARNING!!",
MessageBoxButtons.OK,
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);
}

else if (IsDisplayed == true)
{

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),"Messagebox already
posted");

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);
}
else

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),"Messagebox check
didn't work");

}
catch(InvalidCastException e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"InvalidCast Error #" + e.Message);
}

}
/// <Summary> This method reads data sent by a client from the
received buffer
/// It will post the message into the errorlog, pop up the form onto
the ocs,
/// and send a confirmation back to the client</Summary>
/// <param name="byteBuffer"></param>
/// <param name="size"></param>
///
private void ReceiveData(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);

try
{
if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("failed") > -1))

{
MsgBxDisplayed(byteBuffer, size);
}

else if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("failed.") > -1))
{

MsgBxDisplayed(byteBuffer, size);
}

else if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("rebuilding") > -1) &&
(sData.ToLower().IndexOf("successfully") > -1))
{
// post the message in the error log

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);

}

else if(sData.ToLower().IndexOf(null) > -1)
{

m_stopClient=true;
m_markedForDeletion=true;

}

else
{
// post the message in the error log..to catch what
message is

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"Can't process data" + "::Stopped");
}
}

catch(InvalidCastException e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"InvalidCast Error #" + e.Message);
}

}
}
}
Nov 16 '05 #1
4 1905
Not that I'd sign off on the approach, but to fix your immediate problem,
make sure you set "IsDisplayed" to true when you display your messagebox
(see ****'d line below). Of course, you'll have to use another method to
set IsDisplayed back to false.

--
-Philip Rieck
http://philiprieck.com/blog/

-
"Tressa" <-> wrote in message news:41********@news.qgraph.com...
I have a messagebox that I only want to pop up only if it is not already
being displayed on the screen.

My code is still poping up the messagebox even though it is on the screen.
What am I doing wrong here. Any suggestions on how to fix this
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Web;
using System.Windows.Forms;

using EventListenerOCS;

namespace EventListener
{
/// <Summary> Summary description for SocketListener.</Summary>
public class SocketListener
{
/// <Remarks> Variables that are accessed by other classes
indirectly.</Remarks>
private Socket m_clientSocket = null;
private bool m_stopClient=false;
private Thread m_clientListenerThread=null;
private bool m_markedForDeletion=false;
private bool IsDisplayed=true;

/// <Summary>Client Socket Listener Constructor.</Summary>
/// <param name="clientSocket"></param>
public SocketListener(Socket clientSocket)
{
m_clientSocket = clientSocket;
}

/// <Summary> Client SocketListener Destructor.</Summary>
~SocketListener()
{
StopSocketListener();
}

/// <Summary> Method that starts SocketListener Thread.</Summary>
public void StartSocketListener()
{
if (m_clientSocket!= null)
{
m_clientListenerThread =
new Thread(new ThreadStart(SocketListenerThreadStart));

m_clientListenerThread.Start();
}
}

/// <Summary> Thread method that does the communication to the
client.</Summary>
/// <Remarks> This thread tries to receive data from
client.</remarks>
private void SocketListenerThreadStart()
{
int size=0;
Byte [] byteBuffer = new Byte[1024];

while (!m_stopClient)
{
try
{
size = m_clientSocket.Receive(byteBuffer);
ReceiveData(byteBuffer, size);
}
catch (SocketException se)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"Socket Error #" + se.ErrorCode + ":: " + se.Message);

m_stopClient=true;
m_markedForDeletion=true;
}
}
}

/// <Summary> Method that stops Client SocketListening
Thread.</Summary>
public void StopSocketListener()
{
if (m_clientSocket!= null)
{
m_stopClient=true;
m_clientSocket.Close();

/// <Remarks>Wait for one second for the the thread to
stop.</Remarks>
m_clientListenerThread.Join(1000);

/// <Remarks> If still alive; Get rid of the thread.</Remarks>
if (m_clientListenerThread.IsAlive)
{
m_clientListenerThread.Abort();
}
m_clientListenerThread=null;
m_clientSocket=null;
m_markedForDeletion=true;
}
}

/// <Summary> Method that returns the state of this object</Summary>
/// <Remarks> i.e. whether this object is marked for deletion or
not.<Remarks>
/// <returns></returns>
public bool IsMarkedForDeletion()
{
return m_markedForDeletion;
}
/// <Summary> This method checks to see if the messagebox is
displayed
/// on the XXX already.</Summary>
/// <param name="byteBuffer"></param>
/// <param name="size"></param>
///
private void MsgBxDisplayed(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);
// bool IsDisplayed = false;
try
{

if (IsDisplayed == false)
{ ***** IsDisplayed = true; System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);
// Displays the MessageBox.

MessageBox.Show(" Disk Failure. Call xxxxxx",
"WARNING!!",
MessageBoxButtons.OK,
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);
}

else if (IsDisplayed == true)
{

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),"Messagebox already
posted");

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);
}
else

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),"Messagebox check
didn't work");

}
catch(InvalidCastException e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"InvalidCast Error #" + e.Message);
}

}
/// <Summary> This method reads data sent by a client from the
received buffer
/// It will post the message into the errorlog, pop up the form onto
the ocs,
/// and send a confirmation back to the client</Summary>
/// <param name="byteBuffer"></param>
/// <param name="size"></param>
///
private void ReceiveData(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);

try
{
if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("failed") > -1))

{
MsgBxDisplayed(byteBuffer, size);
}

else if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("failed.") > -1))
{

MsgBxDisplayed(byteBuffer, size);
}

else if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("rebuilding") > -1) &&
(sData.ToLower().IndexOf("successfully") > -1))
{
// post the message in the error log

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);

}

else if(sData.ToLower().IndexOf(null) > -1)
{

m_stopClient=true;
m_markedForDeletion=true;

}

else
{
// post the message in the error log..to catch what
message is

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"Can't process data" + "::Stopped");
}
}

catch(InvalidCastException e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"InvalidCast Error #" + e.Message);
}

}
}
}

Nov 16 '05 #2
bool IsDisplaying = false

void myfunc()
{
if (IsDisplaying == false)
{
IsDisplaying = true;
try
{
MessageBox.Show("hello");
}
finally
{
IsDisplaying = false;
}
}//if (IsDisplaying == false);
else
{
DoSomethingElse()
}

}

if using threads use some kind of thread safe routine for checking
IsDisplaying
Nov 16 '05 #3
Hi,
I havent run your code , but i see that you are creating a thread and from
that thread you are calling a method that create the MessageBox, this is not
the correct way of doing that, a worker thread should not interact with the
UI, you have to make sure that the MessageBox is displayed from the UI
thread, for this you use Control.Invoke

The other thing is that I do not see where you change the value of
IsDisplayed , it should be something like:

if (IsDisplayed == false)
{

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);
// Displays the MessageBox.

isDisplayed = true;

MessageBox.Show(" Disk Failure. Call xxxxxx", "WARNING!!",
MessageBoxButtons.OK,
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);

isDisplayed = false;

}
Hope this help

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tressa" <-> wrote in message news:41********@news.qgraph.com...
I have a messagebox that I only want to pop up only if it is not already
being displayed on the screen.

My code is still poping up the messagebox even though it is on the screen.
What am I doing wrong here. Any suggestions on how to fix this
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Web;
using System.Windows.Forms;

using EventListenerOCS;

namespace EventListener
{
/// <Summary> Summary description for SocketListener.</Summary>
public class SocketListener
{
/// <Remarks> Variables that are accessed by other classes
indirectly.</Remarks>
private Socket m_clientSocket = null;
private bool m_stopClient=false;
private Thread m_clientListenerThread=null;
private bool m_markedForDeletion=false;
private bool IsDisplayed=true;

/// <Summary>Client Socket Listener Constructor.</Summary>
/// <param name="clientSocket"></param>
public SocketListener(Socket clientSocket)
{
m_clientSocket = clientSocket;
}

/// <Summary> Client SocketListener Destructor.</Summary>
~SocketListener()
{
StopSocketListener();
}

/// <Summary> Method that starts SocketListener Thread.</Summary>
public void StartSocketListener()
{
if (m_clientSocket!= null)
{
m_clientListenerThread =
new Thread(new ThreadStart(SocketListenerThreadStart));

m_clientListenerThread.Start();
}
}

/// <Summary> Thread method that does the communication to the
client.</Summary>
/// <Remarks> This thread tries to receive data from
client.</remarks>
private void SocketListenerThreadStart()
{
int size=0;
Byte [] byteBuffer = new Byte[1024];

while (!m_stopClient)
{
try
{
size = m_clientSocket.Receive(byteBuffer);
ReceiveData(byteBuffer, size);
}
catch (SocketException se)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"Socket Error #" + se.ErrorCode + ":: " + se.Message);

m_stopClient=true;
m_markedForDeletion=true;
}
}
}

/// <Summary> Method that stops Client SocketListening
Thread.</Summary>
public void StopSocketListener()
{
if (m_clientSocket!= null)
{
m_stopClient=true;
m_clientSocket.Close();

/// <Remarks>Wait for one second for the the thread to
stop.</Remarks>
m_clientListenerThread.Join(1000);

/// <Remarks> If still alive; Get rid of the thread.</Remarks>
if (m_clientListenerThread.IsAlive)
{
m_clientListenerThread.Abort();
}
m_clientListenerThread=null;
m_clientSocket=null;
m_markedForDeletion=true;
}
}

/// <Summary> Method that returns the state of this object</Summary>
/// <Remarks> i.e. whether this object is marked for deletion or
not.<Remarks>
/// <returns></returns>
public bool IsMarkedForDeletion()
{
return m_markedForDeletion;
}
/// <Summary> This method checks to see if the messagebox is
displayed
/// on the XXX already.</Summary>
/// <param name="byteBuffer"></param>
/// <param name="size"></param>
///
private void MsgBxDisplayed(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);
// bool IsDisplayed = false;
try
{

if (IsDisplayed == false)
{

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);
// Displays the MessageBox.

MessageBox.Show(" Disk Failure. Call xxxxxx",
"WARNING!!",
MessageBoxButtons.OK,
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);
}

else if (IsDisplayed == true)
{

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),"Messagebox already
posted");

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);
}
else

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),"Messagebox check
didn't work");

}
catch(InvalidCastException e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"InvalidCast Error #" + e.Message);
}

}
/// <Summary> This method reads data sent by a client from the
received buffer
/// It will post the message into the errorlog, pop up the form onto
the ocs,
/// and send a confirmation back to the client</Summary>
/// <param name="byteBuffer"></param>
/// <param name="size"></param>
///
private void ReceiveData(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);

try
{
if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("failed") > -1))

{
MsgBxDisplayed(byteBuffer, size);
}

else if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("failed.") > -1))
{

MsgBxDisplayed(byteBuffer, size);
}

else if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("rebuilding") > -1) &&
(sData.ToLower().IndexOf("successfully") > -1))
{
// post the message in the error log

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);

}

else if(sData.ToLower().IndexOf(null) > -1)
{

m_stopClient=true;
m_markedForDeletion=true;

}

else
{
// post the message in the error log..to catch what
message is

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"Can't process data" + "::Stopped");
}
}

catch(InvalidCastException e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"InvalidCast Error #" + e.Message);
}

}
}
}

Nov 16 '05 #4
Hi Tressa,

You don't set IsDisplayed flag to true anywhere in the code. You have one
line that set one local IsDisplayer flag that to false (?!?) has been
commented out. Yes, local flag won't help you, but you forgot to set the
class field IsDisplayed. However in my opinion using flags in multithread
scenarios doesn't give you full threadsafeness. There are always chances
that you may have your message box displayed twise. You need to use some of
the synchronization objects the framework provides
Something like
if(Monitor.TryEnter(syncObject))
{
try
{
MessageBox.Show()

}
finally
{
Monitor.Exit(syncObject)
}
}
else
{
....
}

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Tressa" <-> wrote in message news:41********@news.qgraph.com...
I have a messagebox that I only want to pop up only if it is not already
being displayed on the screen.

My code is still poping up the messagebox even though it is on the screen.
What am I doing wrong here. Any suggestions on how to fix this
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Web;
using System.Windows.Forms;

using EventListenerOCS;

namespace EventListener
{
/// <Summary> Summary description for SocketListener.</Summary>
public class SocketListener
{
/// <Remarks> Variables that are accessed by other classes
indirectly.</Remarks>
private Socket m_clientSocket = null;
private bool m_stopClient=false;
private Thread m_clientListenerThread=null;
private bool m_markedForDeletion=false;
private bool IsDisplayed=true;

/// <Summary>Client Socket Listener Constructor.</Summary>
/// <param name="clientSocket"></param>
public SocketListener(Socket clientSocket)
{
m_clientSocket = clientSocket;
}

/// <Summary> Client SocketListener Destructor.</Summary>
~SocketListener()
{
StopSocketListener();
}

/// <Summary> Method that starts SocketListener Thread.</Summary>
public void StartSocketListener()
{
if (m_clientSocket!= null)
{
m_clientListenerThread =
new Thread(new ThreadStart(SocketListenerThreadStart));

m_clientListenerThread.Start();
}
}

/// <Summary> Thread method that does the communication to the
client.</Summary>
/// <Remarks> This thread tries to receive data from
client.</remarks>
private void SocketListenerThreadStart()
{
int size=0;
Byte [] byteBuffer = new Byte[1024];

while (!m_stopClient)
{
try
{
size = m_clientSocket.Receive(byteBuffer);
ReceiveData(byteBuffer, size);
}
catch (SocketException se)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"Socket Error #" + se.ErrorCode + ":: " + se.Message);

m_stopClient=true;
m_markedForDeletion=true;
}
}
}

/// <Summary> Method that stops Client SocketListening
Thread.</Summary>
public void StopSocketListener()
{
if (m_clientSocket!= null)
{
m_stopClient=true;
m_clientSocket.Close();

/// <Remarks>Wait for one second for the the thread to
stop.</Remarks>
m_clientListenerThread.Join(1000);

/// <Remarks> If still alive; Get rid of the thread.</Remarks>
if (m_clientListenerThread.IsAlive)
{
m_clientListenerThread.Abort();
}
m_clientListenerThread=null;
m_clientSocket=null;
m_markedForDeletion=true;
}
}

/// <Summary> Method that returns the state of this object</Summary>
/// <Remarks> i.e. whether this object is marked for deletion or
not.<Remarks>
/// <returns></returns>
public bool IsMarkedForDeletion()
{
return m_markedForDeletion;
}
/// <Summary> This method checks to see if the messagebox is
displayed
/// on the XXX already.</Summary>
/// <param name="byteBuffer"></param>
/// <param name="size"></param>
///
private void MsgBxDisplayed(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);
// bool IsDisplayed = false;
try
{

if (IsDisplayed == false)
{

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);
// Displays the MessageBox.

MessageBox.Show(" Disk Failure. Call xxxxxx",
"WARNING!!",
MessageBoxButtons.OK,
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);
}

else if (IsDisplayed == true)
{

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),"Messagebox already
posted");

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);
}
else

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),"Messagebox check
didn't work");

}
catch(InvalidCastException e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"InvalidCast Error #" + e.Message);
}

}
/// <Summary> This method reads data sent by a client from the
received buffer
/// It will post the message into the errorlog, pop up the form onto
the ocs,
/// and send a confirmation back to the client</Summary>
/// <param name="byteBuffer"></param>
/// <param name="size"></param>
///
private void ReceiveData(Byte [] byteBuffer, int size)
{
string sData = Encoding.ASCII.GetString(byteBuffer,0, size);

try
{
if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("failed") > -1))

{
MsgBxDisplayed(byteBuffer, size);
}

else if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("failed.") > -1))
{

MsgBxDisplayed(byteBuffer, size);
}

else if((sData.ToLower().IndexOf("disk") > -1) &&
(sData.ToLower().IndexOf("rebuilding") > -1) &&
(sData.ToLower().IndexOf("successfully") > -1))
{
// post the message in the error log

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);

}

else if(sData.ToLower().IndexOf(null) > -1)
{

m_stopClient=true;
m_markedForDeletion=true;

}

else
{
// post the message in the error log..to catch what
message is

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),sData);

System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"Can't process data" + "::Stopped");
}
}

catch(InvalidCastException e)
{
System.Diagnostics.EventLog.WriteEntry(this.ToStri ng(),
"InvalidCast Error #" + e.Message);
}

}
}
}

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeffrey D Moncrieff | last post by:
I am trying to create a data base for colleting date for my research project. I have run in to a couple of problems and I need it fast ASAP I need it to be able to add data and edit them and view...
0
by: VP | last post by:
G'day folks, well i am attempting to get an understanding on how to create the menuitems in a context menu on the fly. So far I have managed to actually achieve the menu items being created for...
19
by: trint | last post by:
Ok, I start my thread job: Thread t = new Thread(new ThreadStart(invoicePrintingLongRunningCodeThread)); t.IsBackground = true; t.Start(); There are lots of calls to controls and many...
2
by: Chad A. Beckner | last post by:
Hey all, I have a ASP .NET webpage which contains several panels. When I click a button on the first "panel" page, it postsback to the same page, and I switch the visibility of the panels...
2
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
1
by: Massimo Bonanni | last post by:
Hi, I try to implement ASAP protocol in my web service, but I find a very hard problem. I define my SOAP Header: public class Request : SoapHeader {
2
by: inquiringMind | last post by:
My academic background is a Master's In Chemistry, and course work in - Undergraduate level classes of Intro C++, Java, Data Structure, Web development using HTML, JavaScript, Perl, JSP...
1
by: jgill | last post by:
Have problems with the recordset…if the value of tempPremium is more than > 10,000 than I get no results after this statement executes: set rsDownPayment =...
0
by: jdprime | last post by:
Hi, I am making a webform, and am trying to populate a dropdownlist with a dataset from a called stored procedure. This is where I run into two problems: 1: How do I get the dropdownlist to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.