Click here to Skip to main content
16,012,198 members
Home / Discussions / C#
   

C#

 
Generaladvantage of interface/abstract class Pin
xcavin2-Jul-04 18:12
xcavin2-Jul-04 18:12 
GeneralRe: advantage of interface/abstract class Pin
Ray Cassick2-Jul-04 18:21
Ray Cassick2-Jul-04 18:21 
GeneralRe: advantage of interface/abstract class Pin
xcavin2-Jul-04 23:34
xcavin2-Jul-04 23:34 
GeneralRe: advantage of interface/abstract class Pin
Vega023-Jul-04 4:30
Vega023-Jul-04 4:30 
GeneralDataGrid & ArrayList Pin
bmasephol2-Jul-04 11:03
bmasephol2-Jul-04 11:03 
GeneralDatagrid Navigation Pin
IamADotNetGuy2-Jul-04 7:30
IamADotNetGuy2-Jul-04 7:30 
GeneralRe: Datagrid Navigation Pin
saud_a_k2-Jul-04 20:07
saud_a_k2-Jul-04 20:07 
GeneralQuestion on events and local variables Pin
Flack2-Jul-04 7:14
Flack2-Jul-04 7:14 
Hello,

In a button click method I create an EventLog, set its EnableRaisingEvents property to true and attach an event handler for the EntryWritten event.

<br />
EventLog eventLog = new EventLog(cbEventLogs.Text,txtMachineName.Text);<br />
<br />
			if(this.txtMachineName.Text == SystemInformation.ComputerName)<br />
			{<br />
				eventLog.EnableRaisingEvents = true;<br />
				eventLog.EntryWritten += new EntryWrittenEventHandler(eventLog_EntryWritten);<br />
}<br />


My question is, how does the event still get fired when you exit the button click method where the event log was created? Doesn't the EventLog variable fall out of scope when the method exits, causing it to be garbage collected?

Thanx for the help,
-Flack
GeneralRe: Question on events and local variables Pin
Karl 20002-Jul-04 9:10
Karl 20002-Jul-04 9:10 
GeneralSaving BMP/JPEG from Stream Pin
Emiliano2-Jul-04 6:53
Emiliano2-Jul-04 6:53 
GeneralRe: Saving BMP/JPEG from Stream Pin
Gimpy19832-Jul-04 6:58
Gimpy19832-Jul-04 6:58 
GeneralRe: Saving BMP/JPEG from Stream Pin
Emiliano2-Jul-04 8:37
Emiliano2-Jul-04 8:37 
GeneralRe: Saving BMP/JPEG from Stream Pin
Gimpy19834-Jul-04 8:28
Gimpy19834-Jul-04 8:28 
GeneralDatagrid column header Pin
Member 5877032-Jul-04 6:33
Member 5877032-Jul-04 6:33 
Generalenum question Pin
Mikke_x2-Jul-04 6:27
Mikke_x2-Jul-04 6:27 
GeneralRe: enum question Pin
Werdna2-Jul-04 12:11
Werdna2-Jul-04 12:11 
GeneralRe: enum question Pin
Mikke_x2-Jul-04 12:49
Mikke_x2-Jul-04 12:49 
GeneralRe: enum question Pin
Colin Angus Mackay2-Jul-04 13:57
Colin Angus Mackay2-Jul-04 13:57 
GeneralRe: enum question Pin
Werdna2-Jul-04 14:38
Werdna2-Jul-04 14:38 
GeneralRe: enum question Pin
Colin Angus Mackay2-Jul-04 14:52
Colin Angus Mackay2-Jul-04 14:52 
GeneralRe: enum question Pin
Werdna2-Jul-04 15:06
Werdna2-Jul-04 15:06 
GeneralRe: enum question Pin
Colin Angus Mackay2-Jul-04 15:19
Colin Angus Mackay2-Jul-04 15:19 
GeneralRe: enum question Pin
Mikke_x3-Jul-04 0:33
Mikke_x3-Jul-04 0:33 
GeneralRe: enum question Pin
Colin Angus Mackay3-Jul-04 12:08
Colin Angus Mackay3-Jul-04 12:08 
GeneralDatagrid Question Pin
C#Coder672-Jul-04 5:42
C#Coder672-Jul-04 5:42 

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.