Click here to Skip to main content
15,894,343 members
Home / Discussions / C#
   

C#

 
QuestionQuestion about ContextMenu on ListView? [modified] Pin
Khoramdin19-Apr-07 13:34
Khoramdin19-Apr-07 13:34 
AnswerRe: Question about ContextMenu on ListView? Pin
Jupiter920-Apr-07 7:38
Jupiter920-Apr-07 7:38 
Questionhow i can change the skin of my form ? Pin
Ahmed R El Bohoty19-Apr-07 12:22
Ahmed R El Bohoty19-Apr-07 12:22 
AnswerRe: how i can change the skin of my form ? Pin
Dmitry Khudorozhkov19-Apr-07 13:01
Dmitry Khudorozhkov19-Apr-07 13:01 
AnswerRe: how i can change the skin of my form ? [modified] Pin
parasaniasandip19-Apr-07 18:53
parasaniasandip19-Apr-07 18:53 
QuestionBlinks on oneClick activation listView Pin
AngryC19-Apr-07 12:06
AngryC19-Apr-07 12:06 
AnswerRe: Blinks on oneClick activation listView [modified] Pin
Dmitry Khudorozhkov19-Apr-07 13:06
Dmitry Khudorozhkov19-Apr-07 13:06 
QuestionC# socket problem Pin
JEC456819-Apr-07 10:32
JEC456819-Apr-07 10:32 
The problem that I'm having is I'm not recieviing all of the data from my socket at 1 time. I'm receiving it in chunks. So I created a custom object that looks for
a specific string then raises a delegate indicating that the entire string was
received. I'm receiving data from 30 different devices so I'm using threads and the thread pool. For some reason every so often my buffer does'nt get cleared out
and the message gets stored wrong into my sql database.

I'm waiting for data with the following method:----------------------

rivate void WaitForData()
{
Waiting = true;

AsyncCallback GetDataCallBack = new AsyncCallback(ProcessData);

StateObject StObj = new StateObject();

StObj.WorkSocket = SockCLient;


//wait for more data
try //If the socket disconnects during the begin receive
{

SockCLient.BeginReceive(StObj.DataBuffer, 0, StObj.DataBuffer.Length,
SocketFlags.None, GetDataCallBack, StObj);

}
catch(Exception Ex)
{

SockCLient.Poll(1000, SelectMode.SelectRead); //this is to poll the socket for 1 second to get the status

if (SockCLient.Connected == false && SocketStillConnected() == false)
{
ConnectToDevice();
}

}
Waiting = false;
}

Receiving the data with the following code:----------------------------------

private void ProcessData(IAsyncResult Asr)
{
Array.Clear(Bytes, 0, Bytes.Length - 1);

StateObject SockId = (StateObject)Asr.AsyncState;

int IEndRec = 0;

try
{

IEndRec = SockId.WorkSocket.EndReceive(Asr);
}
catch
{
}

char[] Chars = new char[IEndRec + 1];

Decoder d = Encoding.UTF8.GetDecoder();

int CharLen = d.GetChars(SockId.DataBuffer, 0, IEndRec, Chars, 0);

//does some more stuff down here

waitfordata();

}

my string appender object looks like this:-------------------------------

public class StringAppender : TextBox
{

public StringAppender()
{
this.Multiline = true;
}

public delegate void TextReceived(string Value);

public event TextReceived TextDataReceived;


public string TextBox
{
get
{
return this.Text;
}
set
{
this.Text = value;
}
}

public void AppendText(string Text, string[] ValuesSearched, bool FirstRun)
{
Text = Text.Replace("\0", "");

if (Text.Length > 0)
{
try
{
this.Text = this.Text + Text;

foreach (string Str in ValuesSearched)
{
if (this.Text.IndexOf(Str) != -1)
{
TextDataReceived(this.Text.Substring(0, this.Text.IndexOf(Str)));

ClearText();
}
}
}
catch (Exception Ex)
{
throw Ex;
}
}
}

public void AppendText(string Text, string ValueSearched, bool FirstRun)
{

Text = Text.Replace("\0", "");

if (Text.Length > 0)
{
try
{
this.Text = this.Text + Text;


if (this.Text.IndexOf(ValueSearched) != -1)
{
TextDataReceived(this.Text.Substring(0, this.Text.IndexOf(ValueSearched)));

ClearText();
}

}
catch (Exception Ex)
{
throw Ex;
}
}

}



public void ClearText()
{
this.Text = "";

}


}

//----------------------------------------------------------------------






Jason E Cain

AnswerRe: C# socket problem Pin
pbraun19-Apr-07 11:49
pbraun19-Apr-07 11:49 
QuestionWriting Another Windows Pin
pouyan_piano19-Apr-07 8:32
pouyan_piano19-Apr-07 8:32 
AnswerRe: Writing Another Windows Pin
Colin Angus Mackay19-Apr-07 8:33
Colin Angus Mackay19-Apr-07 8:33 
JokeRe: Writing Another Windows Pin
Tarakeshwar Reddy19-Apr-07 8:44
professionalTarakeshwar Reddy19-Apr-07 8:44 
AnswerRe: Writing Another Windows Pin
Pete O'Hanlon19-Apr-07 8:47
mvePete O'Hanlon19-Apr-07 8:47 
GeneralRe: Writing Another Windows Pin
Dave Kreskowiak19-Apr-07 9:19
mveDave Kreskowiak19-Apr-07 9:19 
AnswerRe: Writing Another Windows Pin
Dave Kreskowiak19-Apr-07 9:11
mveDave Kreskowiak19-Apr-07 9:11 
GeneralRe: Writing Another Windows Pin
Judah Gabriel Himango19-Apr-07 11:15
sponsorJudah Gabriel Himango19-Apr-07 11:15 
AnswerRe: Writing Another Windows Pin
Luc Pattyn19-Apr-07 11:36
sitebuilderLuc Pattyn19-Apr-07 11:36 
Questionbest ways for multi-user application Pin
hamid_m19-Apr-07 8:15
hamid_m19-Apr-07 8:15 
AnswerRe: best ways for multi-user application Pin
Dave Kreskowiak19-Apr-07 10:16
mveDave Kreskowiak19-Apr-07 10:16 
GeneralRe: best ways for multi-user application Pin
hamid_m19-Apr-07 10:37
hamid_m19-Apr-07 10:37 
GeneralRe: best ways for multi-user application Pin
Dave Kreskowiak19-Apr-07 10:39
mveDave Kreskowiak19-Apr-07 10:39 
GeneralRe: best ways for multi-user application Pin
hamid_m19-Apr-07 10:52
hamid_m19-Apr-07 10:52 
GeneralRe: best ways for multi-user application Pin
Dave Kreskowiak19-Apr-07 15:48
mveDave Kreskowiak19-Apr-07 15:48 
GeneralRe: best ways for multi-user application Pin
hamid_m19-Apr-07 19:49
hamid_m19-Apr-07 19:49 
GeneralRe: best ways for multi-user application Pin
Dave Kreskowiak20-Apr-07 2:01
mveDave Kreskowiak20-Apr-07 2:01 

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.