I read a lot of discussions on topics and topics, but they all focus on “what happens” if I can’t subscribe to the event and try to call him later. My question is different ... what happens if I have a process in thread A that fires the event "I finish" in millisecond 1, and also execute a process in thread B that fires the event "I finish" in millisecond 2.
Both processes eavesdrop on the same method for listening and handling the event. Thus, C # must execute a method that processes the event 2 times: 1 time for the event fired in thread A, and 1 time for the event fired from thread B.
What will happen? C # blocks a method when the "first event coming from thread A" starts execution of a method that processes the event, and unlocks a method when it finishes execution, thereby allowing other expectations of the "event" to execute the method content?
Or an event fired from thread A will start the method that processes the event, and after 1 millisecond, the event that was fired from thread B will also start by the same method, not noticing that this method is currently being executed by another "process" "
I ask this because I want to record a file in a method that catches an event, but if the method can be executed at the same time (depending on when this event is fired), I think I can not do it here, since the information about the file will be a mixture between two processes written to the same file at the same time (incorrect file information).
My code looks like this (a little long, sorry). note that this does not compile, just a sample to show what I'm doing:
public partial class MainForm : Form { FTPClientManager client = null; public MainForm() { InitializeComponent(); } private void btnConnect_Click(object sender, EventArgs e) { Connect(this.tbFTPServer.Text.Trim()); this.lstLog.Items.Add("Connected");
user2232787
source share