Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Bubbling Up Question

$
0
0

Hello,

Having a bit of trouble wrapping my head around this.  I have 2 classes that are in 2 separate .cs files.

We connect to the network host then capture the buffer and send the buffer to scoreParser.Parse(buffer) to be parsed

internal class ConnectionThread 
{
private ScoreParser scoreParser = new ScoreParser();
.
.
.

private void ComThread()
{
networks.Read(buffer, 0, 1024);
scoreParser.Parse(buffer);

}
.
.
.
public event EventHandler<RunDataParsedEventArgs> RunDataReceived;

        private void RaiseRunDataReceived(RunDataParsedEventArgs args)
        {
            if (RunDataReceived != null)
            {
                RunDataReceived(this, args);
            }
        }

}

To get parsed it goes to this class (in a different file) to be parsed.

public class ScoreParse { public class RunData { public int UNumber { get; set; } public string Description { get; set; } public DateTime TDStamp { get; set; } } . . . // public void Parse(byte[] buffer) { string str = Encoding.Default.GetString(buffer, 0,buffer.Length); string[] tempRecords = str.Split('\n'); // Split record apart to get fields string[] recordFields = tempRecords[x].Split(','); // Massage buffer to get it how I want it and stick parsed fields into properties of RunData class (works fine) RunData rundata = new RunData(); rundata.UNumber = recordFields[0]; rundata.Description = recordFields[1]; rundata.TDStamp = recordFields[2]; // Great, rundata is now loaded. // Event to fire to bubble up rundata back up to scoreParser? Would it go here and how do I do it? }

My question is, how do I fire an event off that will bubble up rundata back up to the scoreParser class?

There is a lot of inbetween code missing but trust me, rundata does get loaded by the parsing and splitting of the buffer.

Thanks in advance.

Tanya


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>