System.Security.SecureString.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
		public void Dispose ()
		{
			disposed = true;
			// don't call clear because we could be either in read-only 
			// or already disposed - but DO CLEAR the data
			if (data != null) {
				Array.Clear (data, 0, data.Length);
				data = null;
			}
			length = 0;
		}

Usage Example

        private void check_log(string name) {
            try {
                SecureString pwd = new SecureString();
                foreach ( char c in remote_passw_)
                    pwd.AppendChar(c);
                EventLogSession session = remote_machine_name_ != "" ? new EventLogSession(remote_machine_name_, remote_domain_, remote_username_, pwd, SessionAuthentication.Default) : null;
                pwd.Dispose();
                string query_string = "*";
                EventLogQuery query = new EventLogQuery(name, PathType.LogName, query_string);

                using (EventLogReader reader = new EventLogReader(query))
                    for (EventRecord rec = reader.ReadEvent(); rec != null; rec = reader.ReadEvent())
                        lock (this) 
                            --log_names_[name];

            } catch (Exception e) {
                logger.Error("error checking log " + name + " on " + remote_machine_name_ + " : " + e.Message);
            }

            // mark log as fully read
            lock (this) {
                log_names_[name] = -log_names_[name];
                if (log_names_[name] == 0)
                    // convention - 0 entries
                    log_names_[name] = int.MinValue;
            }
        }
All Usage Examples Of System.Security.SecureString::Dispose