Here are the examples of the csharp api System.Timers.Timer.Stop() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1032 Examples
19
Source : Lsnn.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[Command("choppercam"), Help(HelpManager.CommandGroups.LSNN, "Toggle the chopper cam on/off", null )]
public void choppercam_cmd(Player player)
{
Character character = player.GetCharacter();
if (character.Group == Group.None || character.Group.CommandType != Group.CommandTypeLsnn)
{
NAPI.Chat.SendChatMessageToPlayer(player, core.Color.White, "You must be a member of the LSNN to use that command.");
return;
}
var vehicleHandle = NAPI.Player.GetPlayerVehicle(player);
var veh = VehicleManager.GetVehFromNetHandle(vehicleHandle);
if (character.Group.Id != veh.GroupId && veh.VehModel != VehicleHash.Maverick)
{
NAPI.Chat.SendChatMessageToPlayer(player, "You must be in an LSNN chopper to use the chopper camera.");
return;
}
if (CameraSet == true && ChopperCamToggle == false)
{
NAPI.Chat.SendChatMessageToPlayer(player, "A camera has already been set. /pickupcamera before using the chopper cam.");
return;
}
if (ChopperCamToggle == true)
{
if (IsBroadcasting == true)
{
foreach (var c in NAPI.Pools.GetAllPlayers())
{
if (c == null)
continue;
Character receivercharacter = c.GetCharacter();
if (receivercharacter == null)
continue;
if (receivercharacter.IsWatchingBroadcast)
{
NAPI.ClientEvent.TriggerClientEvent(c, "unwatch_broadcast");
receivercharacter.IsWatchingBroadcast = false;
NAPI.Chat.SendChatMessageToPlayer(c, "~p~The LSNN camera has been turned off.");
}
}
}
NAPI.Notification.SendNotificationToPlayer(player, "The chopper camera has been turned ~r~off~w~.");
ChatManager.NearbyMessage(player, 10, "~p~" + character.rp_name() + " has turned off the chopper cam.");
CameraPosition = new Vector3();
CameraRotation = new Vector3();
CameraSet = false;
ChopperCamToggle = false;
ChopperRotation.Stop();
return;
}
CameraSet = true;
ChopperCamToggle = true;
Chopper = NAPI.Player.GetPlayerVehicle(player);
CameraPosition = NAPI.Enreplacedy.GetEnreplacedyPosition(Chopper) - new Vector3(0, 0, 3);
CameraRotation = NAPI.Enreplacedy.GetEnreplacedyRotation(Chopper);
NAPI.Notification.SendNotificationToPlayer(player, "The chopper camera has been turned ~b~on~w~.");
ChatManager.NearbyMessage(player, 10, "~p~" + character.rp_name() + " has turned on the chopper cam.");
ChopperRotation = new Timer { Interval = 3000 };
ChopperRotation.Elapsed += delegate { UpdateChopperRotation(player); };
ChopperRotation.Start();
}
19
Source : GunrunnerManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
private void DeleteZoneMarker(Player player)
{
NAPI.ClientEvent.TriggerClientEvent(player, "delete_zone_marker");
ZoneTimer.Stop();
}
19
Source : TreeItem.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
public void RespawnTimer_Elapsed(object sender, ElapsedEventArgs e)
{
RespawnTimer.Stop();
Stage = Stages.Cutting;
CutPercentage = 0;
ProcessPercentage = 0;
UpdateAllTree();
}
19
Source : PlayerManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[ServerEvent(Event.PlayerDisconnected)]
public void OnPlayerDisconnected(Player player, byte type, string reason)
{
//Save data
Character character = player.GetCharacter();
if (character != null)
{
var account = player.GetAccount();
if (account.AdminLevel > 0)
{
foreach (var p in Players)
{
if (p.Player.GetAccount().AdminLevel > 0)
{
p.Player.SendChatMessage($"Admin {account.AdminName} has left the server.");
}
}
}
if (character.Group != Group.None)
{
GroupManager.SendGroupMessage(player,
character.rp_name() + " from your group has left the server. (" + reason + ")");
}
account.Save();
character.Save();
//Stop all timers
foreach (var timerVar in typeof(Character).GetProperties().Where(x => x.PropertyType == typeof(Timer)))
{
var tim = (Timer)timerVar.GetValue(character);
tim?.Stop();
}
RemovePlayer(character);
LogManager.Log(LogManager.LogTypes.Connection, $"{character.CharacterName}[{player.SocialClubName}] has left the server.");
}
else
LogManager.Log(LogManager.LogTypes.Connection, $"{player.SocialClubName} has left the server. (Not logged into a character)");
}
19
Source : Advertising.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
public void ResetAdvertTimer()
{
AdvertTimer.Stop();
CanAdvertise = true;
}
19
Source : FullScreenWindow.xaml.cs
with Apache License 2.0
from beckzhu
with Apache License 2.0
from beckzhu
public void MouseMoveProc(int x, int y)
{
if (!_connectionBar_IsVisible && y < 5 && x > _connectionBar_Rect.Left && x < _connectionBar_Rect.Left + _connectionBar_Rect.Width)
{
if (_timer == null)
{
_timer = new System.Timers.Timer(500);
_timer.AutoReset = false;
_timer.Enabled = true;
_timer.Elapsed += (s, e) =>
{
Dispatcher.Invoke(() =>
{
if (!PART_connectionBar.IsVisible)
{
PART_connectionBar.Visibility = Visibility.Visible;
var bAnimation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.4)));
PART_connectionBar.BeginAnimation(OpacityProperty, bAnimation);
}
});
_timer = null;
};
}
}
else
{
if (_timer != null)
{
_timer?.Stop();
_timer = null;
}
}
}
19
Source : ModulatorMod.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
public override void OnDisable()
{
timeDrain.Stop();
}
19
Source : ModulatorMod.cs
with MIT License
from BelkinAndrey
with MIT License
from BelkinAndrey
public void onActionNeuron() //По событию активации нейрона
{
if (thresholdMod == 0) //Если нет модулирующего воздействия
{
timeEvaluation.Elapsed -= evaluationTime; //Останавливаем время оценки
timeEvaluation.Stop();
timeEvaluation.Dispose();
if (Evaluat) //Сейча время оценки
{
iteration++; //Считаем повторы
}
else
{
iteration = 0;
} //Время оценки вышло, обнуляем счётчик повторов
if (iteration > IterationLimit) //Если лимит повторов превышен
{
(base.parent.summator as SummatorSimple).threshold += thresholdUp; //Увеличиваем порог на заданный шаг
}
timer.Change(Timeout.Infinite, Timeout.Infinite);
}
}
19
Source : MainViewModel.cs
with MIT License
from Berrysoft
with MIT License
from Berrysoft
protected override async Task<LogResponse> RefreshAsync(IConnect helper)
{
var res = await base.RefreshAsync(helper);
mainTimer.Stop();
OnlineTime = OnlineUser.OnlineTime;
if (!string.IsNullOrEmpty(OnlineUser.Username))
mainTimer.Start();
var maxf = FluxHelper.GetMaxFlux(OnlineUser.Flux, OnlineUser.Balance);
FluxOffset = (float)(OnlineUser.Flux / maxf);
FreeOffset = (float)Math.Max(FluxHelper.BaseFlux / maxf, FluxOffset);
OnRefreshed(EventArgs.Empty);
return res;
}
19
Source : DefaultTooltip.xaml.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
void IChartTooltip<SkiaSharpDrawingContext>.Show(IEnumerable<TooltipPoint> tooltipPoints, Chart<SkiaSharpDrawingContext> chart)
{
var mobileChart = (IMobileChart)chart.View;
Points = tooltipPoints;
LvcPoint? location = null;
var size = new Size
{
Width = Width * DeviceDisplay.MainDisplayInfo.Density,
Height = Height * DeviceDisplay.MainDisplayInfo.Density
};
if (chart is CartesianChart<SkiaSharpDrawingContext> or PolarChart<SkiaSharpDrawingContext>)
{
location = tooltipPoints.GetCartesianTooltipLocation(
chart.TooltipPosition, new LvcSize((float)size.Width, (float)size.Height), chart.ControlSize);
}
if (chart is PieChart<SkiaSharpDrawingContext>)
{
location = tooltipPoints.GetPieTooltipLocation(
chart.TooltipPosition, new LvcSize((float)size.Width, (float)size.Height));
}
if (location is null) throw new Exception("location not supported");
IsVisible = true;
var template = mobileChart.TooltipTemplate ?? _defaultTemplate;
if (TooltipTemplate != template) TooltipTemplate = template;
TooltipFontFamily = mobileChart.TooltipFontFamily;
TooltipTextColor = mobileChart.TooltipTextBrush;
TooltipFontSize = mobileChart.TooltipFontSize;
TooltipFontAttributes = mobileChart.TooltipFontAttributes;
TooltipBackgroundColor = mobileChart.TooltipBackground;
BuildContent();
InvalidateLayout();
_ = Measure(double.PositiveInfinity, double.PositiveInfinity);
var chartSize = chart.ControlSize;
_chart = chart;
AbsoluteLayout.SetLayoutBounds(
this,
new Rectangle(
location.Value.X / chartSize.Width,
location.Value.Y / chartSize.Height,
AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
_closeTimer.Stop();
_closeTimer.Start();
}
19
Source : DefaultTooltip.xaml.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
private void _closeTimer_Elapsed(object sender, ElapsedEventArgs e)
{
((IChartTooltip<SkiaSharpDrawingContext>)this).Hide();
_closeTimer.Stop();
}
19
Source : DanmakuClient.cs
with GNU General Public License v3.0
from Bililive
with GNU General Public License v3.0
from Bililive
public async Task DisconnectAsync()
{
await this.semapreplacedSlim.WaitAsync().ConfigureAwait(false);
try
{
this.danmakuStream?.Dispose();
this.danmakuStream = null;
this.timer.Stop();
}
finally
{
this.semapreplacedSlim.Release();
}
StatusChanged?.Invoke(this, StatusChangedEventArgs.False);
}
19
Source : WebSocketConnection.cs
with GNU Lesser General Public License v2.1
from Blancworks
with GNU Lesser General Public License v2.1
from Blancworks
public async Task<bool> SetupConnection()
{
Logger.LogMessage("Setup connection!");
//First, grab the JWT for the client.
byte[] jwtMessage = await GetNextMessage();
if (jwtMessage.Length == 0)
{
Logger.LogMessage("No JWT received");
return false;
}
try
{
//Get token from string.
string token = GetStringFromMessage(jwtMessage);
Logger.LogMessage("Token is " + token);
//Verify token.
if (AuthenticationManager.IsTokenValid(token, out var claims))
{
//Token verified, pull user UUID from the JWT.
playerID = Guid.Parse(claims.First().Value);
Logger.LogMessage("Connection verified for player " + playerID);
//Get the client registry message.
byte[] registryMessage = await GetNextMessage();
using var ms = new MemoryStream(registryMessage);
using var br = new BinaryReader(ms, Encoding.UTF8);
Registry.ReadRegistryMessage(br);
await SendServerRegistry();
//Get a group, or create one if needed.
var timerGroupPair = rateLimitGroups.GetOrAdd(playerID, (guid) =>
{
RateLimiterGroup ng = new RateLimiterGroup();
Timer t = new Timer(60000);
t.Elapsed += (_, _) => {
rateLimitGroups.TryRemove(guid, out _);
t.Stop();
};
return new Tuple<Timer, RateLimiterGroup>(t, ng);
});
//Stop timer that we've grabbed
timerGroupPair.Item1.Stop();
//Set our rate group to the given group
rateGroup = timerGroupPair.Item2;
Logger.LogMessage("Open connection for player ID " + playerID.ToString());
openedConnections.AddOrUpdate(playerID, this, (k, v) => this);
PubSubManager.Subscribe(playerID, playerID);
}
else
{
Logger.LogMessage("Invalid Token.");
await socket.CloseAsync(WebSocketCloseStatus.PolicyViolation, "Invalid Authentication", CancellationToken.None);
return false;
}
}
catch (Exception e)
{
Logger.LogMessage(e);
await socket.CloseAsync(WebSocketCloseStatus.PolicyViolation, "Error During Setup", CancellationToken.None);
return false;
}
return true;
}
19
Source : RoomMessages.razor.cs
with MIT License
from Blazored
with MIT License
from Blazored
protected override async Task OnParametersSetAsync()
{
await base.OnParametersSetAsync();
if (!ChatRoom.Equals(LastRoom))
{
LoadingMessages = true;
LastRoom = ChatRoom;
RoomWatcher?.Stop();
NoMoreOldMessages = false;
IsFetchingOlder = false;
Messages = new List<IChatMessage>();
StartRoomWatcher();
LoadingMessages = false;
FirstLoad = true;
}
}
19
Source : RoomMessages.razor.cs
with MIT License
from Blazored
with MIT License
from Blazored
async Task MonitorNewMessages()
{
RoomWatcher.Stop();
if (RoomWatcher.Interval == 250)
{
RoomWatcher.Interval = 2000;
}
var options = GitterApi.GetNewOptions();
options.Lang = Localisation.LocalCultureInfo.Name;
options.AfterId = "";
//bool bottom = false;
//try
//{
// bottom = await JSRuntime.IsScrolledToBottom("blgmessagelist");
//}
//catch
//{
//}
if (Messages?.Any() ?? false)
{
options.AfterId = GetLastMessageId();
}
await FetchNewMessages(options, tokenSource.Token);
//if (Messages?.Any() ?? false)
//{
// if (bottom)
// {
// _ = await JSRuntime.ScrollIntoView(GetLastMessageId());
// }
//}
RoomWatcher?.Start();
}
19
Source : ChatRoomList.razor.cs
with MIT License
from Blazored
with MIT License
from Blazored
public void Dispose()
{
State.GotChatRooms -= RefreshRooms;
ChatRoomTimer.Elapsed -= ChatRoomTimer_Elapsed;
ChatRoomTimer?.Stop();
ChatRoomTimer?.Dispose();
}
19
Source : RoomMessages.razor.cs
with MIT License
from Blazored
with MIT License
from Blazored
public void Dispose()
{
State.ActivityTimeout -= ActivityTimeout;
State.ActivityResumed -= ActivityResumed;
RoomWatcher?.Stop();
RoomWatcher?.Dispose();
Messages = null;
RoomWatcher = null;
}
19
Source : RoomMessages.razor.cs
with MIT License
from Blazored
with MIT License
from Blazored
private void ActivityTimeout(object sender, EventArgs e)
{
try
{
RoomWatcher?.Stop();
Paused = true;
InvokeAsync(StateHasChanged);
}
catch
{
}
}
19
Source : ContextualMenuItem.cs
with MIT License
from BlazorFluentUI
with MIT License
from BlazorFluentUI
private async void EnterTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
await InvokeAsync(() =>
{
enterTimer.Stop();
if (Items != null)
SetSubmenu.InvokeAsync(Key);
else
SetSubmenu.InvokeAsync(null);
});
}
19
Source : Slider.razor.cs
with MIT License
from BlazorFluentUI
with MIT License
from BlazorFluentUI
private void ClearOnKeyDownTimer()
{
timer.Stop();
}
19
Source : TooltipHost.razor.cs
with MIT License
from BlazorFluentUI
with MIT License
from BlazorFluentUI
private void openTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
InvokeAsync(() =>
{
openTimer?.Stop();
ToggleTooltip(true);
});
}
19
Source : TooltipHost.razor.cs
with MIT License
from BlazorFluentUI
with MIT License
from BlazorFluentUI
private void dismissTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
InvokeAsync(() =>
{
dismissTimer?.Stop();
ToggleTooltip(false);
});
}
19
Source : TooltipHost.razor.cs
with MIT License
from BlazorFluentUI
with MIT License
from BlazorFluentUI
protected Task OnTooltipMouseEnter(EventArgs args)
{
Debug.WriteLine("OnMouseEnter");
if (CurrentVisibleTooltip != null && CurrentVisibleTooltip != this)
CurrentVisibleTooltip.Dismiss();
CurrentVisibleTooltip = this;
if (OverflowMode != TooltipOverflowMode.None)
{
DetermineTargetElement();
// test for overflow... return and do nothing if there is none
// for now, let's not show the tooltip until the detection for overflow works
return Task.CompletedTask;
}
// do another test to see if tooltip target is inside a portal relative to the tooltiphost. Probably won't deal with this for a while.
// return and do nothing if so...
dismissTimer?.Stop();
openTimer?.Stop();
if (Delay != TooltipDelay.Zero)
{
IsAriaPlaceholderRendered = true;
double delayTime = GetDelayTime(Delay);
if (openTimer != null)
{
openTimer.Interval = delayTime;
openTimer.Start();
}
}
else
{
ToggleTooltip(true);
}
return Task.CompletedTask;
}
19
Source : TooltipHost.razor.cs
with MIT License
from BlazorFluentUI
with MIT License
from BlazorFluentUI
protected Task OnTooltipMouseLeave(EventArgs args)
{
if (dismissTimer != null) // component can be disposed already and still return this event
{
Debug.WriteLine("OnMouseLeave");
dismissTimer.Stop();
openTimer?.Stop();
if (!double.IsNaN(CloseDelay))
{
dismissTimer.Interval = CloseDelay;
dismissTimer.Start();
}
else
{
ToggleTooltip(false);
}
if (TooltipHost.CurrentVisibleTooltip == this)
{
TooltipHost.CurrentVisibleTooltip = null;
}
}
return Task.CompletedTask;
}
19
Source : AppState.cs
with MIT License
from Blazored
with MIT License
from Blazored
private void SetTimeoutTime()
{
if (!(TimeoutTimer is object))
{
TimeoutTimer = new Timer() { AutoReset = false, Interval = new TimeSpan(0, TIMEOUT, 0).TotalMilliseconds };
TimeoutTimer.Elapsed += TimeoutTimer_Elapsed;
}
if (TimeoutTimer.Enabled)
{
TimeoutTimer.Stop();
}
else
{
RaiseActivityResumedEvent();
}
TimeoutTime = DateTime.UtcNow.AddMinutes(TIMEOUT);
TimeoutTimer.Start();
if (!(LastTriggerTimeOutChanged is object))
{
LastTriggerTimeOutChanged = new Stopwatch();
}
if (!LastTriggerTimeOutChanged.IsRunning || LastTriggerTimeOutChanged.ElapsedMilliseconds >= 1000)
{
RaiseTimeoutChangedEvent(TimeoutTime);
LastTriggerTimeOutChanged.Restart();
}
}
19
Source : RichTextEditor.razor.cs
with MIT License
from BlazorFluentUI
with MIT License
from BlazorFluentUI
[JSInvokable]
public Task TextChangedAsync(TextChangedArgs args)
{
//if (args.Source != ChangeSource.User)
{
if (_debounceTextTimer.Enabled)
_debounceTextTimer.Stop();
internalRichText = args.Html;
if (args.Html != RichText)
{
_waitingText = args.Html;
_debounceTextTimer.Start();
}
}
return Task.CompletedTask;
}
19
Source : RichTextEditor.razor.cs
with MIT License
from BlazorFluentUI
with MIT License
from BlazorFluentUI
[JSInvokable]
public Task SelectionChangedAsync(FormattingState formattingState)
{
if (_debounceSelectionTimer.Enabled)
_debounceSelectionTimer.Stop();
_waitingFormattingState = formattingState;
_debounceSelectionTimer.Start();
return Task.CompletedTask;
}
19
Source : InputManagerService.cs
with MIT License
from blish-hud
with MIT License
from blish-hud
public void Stop() {
if (thread == null) return;
timeoutTimer.Stop();
messageService.Unregister<PingMessage>();
stopRequested = true;
thread.Join();
stopRequested = false;
thread = null;
}
19
Source : InputManagerService.cs
with MIT License
from blish-hud
with MIT License
from blish-hud
private void HandlePing(PingMessage message) {
timeoutTimer.Stop();
timeoutTimer.Start();
hookRequested = true;
}
19
Source : CounterBox.cs
with MIT License
from blish-hud
with MIT License
from blish-hud
private void ResetHoldTimer() {
_holdTimer.Stop();
_holdTimer.Dispose();
_holdTimer = new Timer(HOLD_MILISECONDS);
_holdTimerFast.Reset();
}
19
Source : DebugHelperHookManager.cs
with MIT License
from blish-hud
with MIT License
from blish-hud
public void Unload() {
Logger.Debug("Unloading DebugHelper input hooks");
_debugHelperMessageService.Stop();
_pingTimer.Stop();
Logger.Debug("Killing subprocess with id {ProcessId}", _process.Id);
if (!_process.HasExited) _process.Kill();
_debugHelperMessageService = null;
_process = null;
}
19
Source : ConnectionStatusView.cs
with MIT License
from blish-hud
with MIT License
from blish-hud
protected override void Unload() {
_updateTimer.Stop();
_updateTimer.Elapsed -= UiUpdateTimerElapsed;
_updateTimer.Dispose();
}
19
Source : GroupEnumerationTasks.cs
with GNU General Public License v3.0
from BloodHoundAD
with GNU General Public License v3.0
from BloodHoundAD
private static async Task GetGroupMembership(Group group)
{
var finalMembers = new List<GenericMember>();
var searchResult = group.SearchResult;
AppCache.Add(group.DistinguishedName, new ResolvedPrincipal
{
ObjectIdentifier = group.ObjectIdentifier,
ObjectType = LdapTypeEnum.Group
});
var groupMembers = searchResult.GetPropertyAsArray("member");
//If we get 0 back for member length, its either a ranged retrieval issue, or its an empty group.
if (groupMembers.Length == 0)
{
Timer timer = null;
var count = 0;
//Lets try ranged retrieval here
var searcher = Helpers.GetDirectorySearcher(group.Domain);
var range = await searcher.RangedRetrievalAsync(group.DistinguishedName, "member");
//If we get null back, then something went wrong.
if (range == null)
{
group.Members = finalMembers.ToArray();
return;
}
if (range.Count > 1000 && Options.Instance.Verbose)
{
timer = new Timer(30000);
timer.Elapsed += (sender, args) =>
{
Console.WriteLine($"Group Enumeration - {group.DisplayName} {count} / {range.Count}");
};
timer.AutoReset = true;
timer.Start();
}
foreach (var groupMemberDistinguishedName in range)
{
var (sid, type) = await ResolutionHelpers.ResolveDistinguishedName(groupMemberDistinguishedName);
if (sid == null)
sid = groupMemberDistinguishedName;
finalMembers.Add(new GenericMember
{
MemberId = sid,
MemberType = type
});
count++;
}
timer?.Stop();
timer?.Dispose();
}
else
{
//We got our members back
foreach (var groupMemberDistinguishedName in groupMembers)
{
//Resolve DistinguishedNames to SIDS
var (sid, type) = await ResolutionHelpers.ResolveDistinguishedName(groupMemberDistinguishedName);
if (sid == null)
sid = groupMemberDistinguishedName;
finalMembers.Add(new GenericMember
{
MemberId = sid,
MemberType = type
});
}
}
group.Members = finalMembers.Distinct().ToArray();
}
19
Source : OutputTasks.cs
with GNU General Public License v3.0
from BloodHoundAD
with GNU General Public License v3.0
from BloodHoundAD
internal static async Task CompleteOutput()
{
PrintStatus();
Console.WriteLine($"Enumeration finished in {_runTimer.Elapsed}");
if (Options.Instance.DumpComputerStatus)
{
CompleteComputerStatusOutput();
await _computerStatusTask;
}
var domainName = Helpers.NormalizeDomainName(Options.Instance.Domain);
var forestName = Helpers.GetForestName(domainName).ToUpper();
var dcSids = BaseProducer.GetDomainControllers();
var domainSid = new SecurityIdentifier(dcSids.First().Key).AccountDomainSid.Value.ToUpper();
var enterpriseDomainControllers = new Group(null)
{
ObjectIdentifier = $"{forestName}-S-1-5-9",
Domain = forestName,
Members = BaseProducer.GetDomainControllers().Keys.Select(sid => new GenericMember
{
MemberId = sid,
MemberType = LdapTypeEnum.Computer
}).ToArray()
};
enterpriseDomainControllers.Properties.Add("name", $"ENTERPRISE DOMAIN CONTROLLERS@{forestName}");
enterpriseDomainControllers.Properties.Add("domain", forestName);
_groupOutput.Value.WriteObject(enterpriseDomainControllers);
var members = new[]
{
new GenericMember
{
MemberType = LdapTypeEnum.Group,
MemberId = $"{domainSid}-515"
},
new GenericMember
{
MemberType = LdapTypeEnum.Group,
MemberId = $"{domainSid}-513"
}
};
var everyone = new Group(null)
{
ObjectIdentifier = $"{domainName}-S-1-1-0",
Domain = domainName,
Members = members
};
everyone.Properties.Add("name", $"EVERYONE@{domainName}");
everyone.Properties.Add("domain", domainName);
_groupOutput.Value.WriteObject(everyone);
var authUsers = new Group(null)
{
ObjectIdentifier = $"{domainName}-S-1-5-11",
Domain = domainName,
Members = members
};
authUsers.Properties.Add("name", $"AUTHENTICATED USERS@{domainName}");
authUsers.Properties.Add("domain", domainName);
_groupOutput.Value.WriteObject(authUsers);
//Write objects for common principals
foreach (var seen in SeenCommonPrincipals)
{
var domain = seen.Key;
var sid = seen.Value;
CommonPrincipal.GetCommonSid(sid, out var principal);
sid = Helpers.ConvertCommonSid(sid, domain);
switch (principal.Type)
{
case LdapTypeEnum.User:
var u = new User(null)
{
ObjectIdentifier = sid
};
u.Properties.Add("name", $"{principal.Name}@{domain}".ToUpper());
u.Properties.Add("domain", domain);
_userOutput.Value.WriteObject(u);
break;
case LdapTypeEnum.Computer:
var c = new Computer(null)
{
ObjectIdentifier = sid
};
c.Properties.Add("name", $"{principal.Name}@{domain}".ToUpper());
c.Properties.Add("domain", domain);
_computerOutput.Value.WriteObject(c);
break;
case LdapTypeEnum.Group:
var g = new Group(null)
{
ObjectIdentifier = sid
};
g.Properties.Add("name", $"{principal.Name}@{domain}".ToUpper());
g.Properties.Add("domain", domain);
_groupOutput.Value.WriteObject(g);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
_runTimer.Stop();
_statusTimer.Stop();
if (_userOutput.IsValueCreated)
_userOutput.Value.CloseWriter();
if (_computerOutput.IsValueCreated)
_computerOutput.Value.CloseWriter();
if (_groupOutput.IsValueCreated)
_groupOutput.Value.CloseWriter();
if (_domainOutput.IsValueCreated)
_domainOutput.Value.CloseWriter();
if (_gpoOutput.IsValueCreated)
_gpoOutput.Value.CloseWriter();
if (_ouOutput.IsValueCreated)
_ouOutput.Value.CloseWriter();
_userOutput = new Lazy<JsonFileWriter>(() => new JsonFileWriter("users"), false);
_groupOutput = new Lazy<JsonFileWriter>(() => new JsonFileWriter("groups"), false);
_computerOutput = new Lazy<JsonFileWriter>(() => new JsonFileWriter("computers"), false);
_domainOutput = new Lazy<JsonFileWriter>(() => new JsonFileWriter("domains"), false);
_gpoOutput = new Lazy<JsonFileWriter>(() => new JsonFileWriter("gpos"), false);
_ouOutput = new Lazy<JsonFileWriter>(() => new JsonFileWriter("ous"), false);
string finalName;
var options = Options.Instance;
if (options.NoZip || options.NoOutput)
return;
if (options.ZipFilename != null)
finalName = Helpers.ResolveFileName(Options.Instance.ZipFilename, "zip", true);
else
{
finalName = Helpers.ResolveFileName("BloodHound", "zip", true);
}
Console.WriteLine($"Compressing data to {finalName}");
var buffer = new byte[4096];
if (File.Exists(finalName))
{
Console.WriteLine("Zip File already exists, randomizing filename");
finalName = Helpers.ResolveFileName(Path.GetRandomFileName(), "zip", true);
Console.WriteLine($"New filename is {finalName}");
}
using (var zipStream = new ZipOutputStream(File.Create(finalName)))
{
//Set level to 9, maximum compressions
zipStream.SetLevel(9);
if (options.EncryptZip)
{
if (!options.Loop)
{
var preplacedword = ZipPreplacedwords.Value;
zipStream.Preplacedword = preplacedword;
Console.WriteLine($"Preplacedword for Zip file is {preplacedword}. Unzip files manually to upload to interface");
}
}
else
{
Console.WriteLine("You can upload this file directly to the UI");
}
foreach (var file in UsedFileNames)
{
var entry = new ZipEntry(Path.GetFileName(file)) { DateTime = DateTime.Now };
zipStream.PutNextEntry(entry);
using (var fileStream = File.OpenRead(file))
{
int source;
do
{
source = await fileStream.ReadAsync(buffer, 0, buffer.Length);
zipStream.Write(buffer, 0, source);
} while (source > 0);
}
File.Delete(file);
}
zipStream.Finish();
}
if (options.Loop)
ZipFileNames.Add(finalName);
UsedFileNames.Clear();
}
19
Source : NukiBridge2MqttLogic.cs
with Apache License 2.0
from bluewalk
with Apache License 2.0
from bluewalk
private void Initialize(string mqttHost, int? mqttPort, string mqttRootTopic, string callbackAddress,
int? callbackPort, string bridgeUrl, string token, bool hashToken, int? infoInterval)
{
_mqttRootTopic = !string.IsNullOrEmpty(mqttRootTopic) ? mqttRootTopic : "nukibridge";
_mqttHost = !string.IsNullOrEmpty(mqttHost) ? mqttHost : "localhost";
_mqttPort = mqttPort ?? 1883;
_bridgeUrl = !string.IsNullOrEmpty(bridgeUrl) ? bridgeUrl : NukiBridgeClient.DiscoverBridge();
_bridgeToken = token;
if (string.IsNullOrEmpty(_bridgeUrl) ||
string.IsNullOrEmpty(_bridgeToken))
throw new Exception("No Bridge_URL and/or Bridge_Token defined");
_hashToken = hashToken;
// Setup MQTT
_mqttClient = new MqttFactory().CreateManagedMqttClient();
_mqttClient.UseApplicationMessageReceivedHandler(e => MqttClientOnApplicationMessageReceived(e));
_mqttClient.UseConnectedHandler(e =>
{
Log.Information("MQTT: Connected");
SubscribeTopic("discover");
SubscribeTopic("reset");
SubscribeTopic("reboot");
SubscribeTopic("fw-upgrade");
});
_mqttClient.UseDisconnectedHandler(e =>
{
if (e.ClientWasConnected)
Log.Warning($"MQTT: Disconnected ({e.Exception?.Message ?? "clean"})");
else
Log.Error($"MQTT: Unable to connect ({e.Exception?.Message ?? "clean"})");
});
_nukiBridgeClient = new NukiBridgeClient(_bridgeUrl, _bridgeToken, _hashToken);
// Setup callback
_callbackAddress = callbackAddress ?? LocalIpAddress().ToString();
_callbackPort = callbackPort ?? 8080;
_httpListener = new HttpListener
{
Prefixes = { $"http://+:{_callbackPort}/" }
};
_devices = new List<Device>();
// Prevent info interval being set to 0
if ((infoInterval ?? 0) == 0)
infoInterval = 300;
// Setup info interval
_infoTimer = new Timer((infoInterval ?? 300) * 1000);
_infoTimer.Elapsed += async (sender, args) =>
{
_infoTimer.Stop();
await PublishBridgeInfo();
_infoTimer.Start();
};
}
19
Source : NukiBridge2MqttLogic.cs
with Apache License 2.0
from bluewalk
with Apache License 2.0
from bluewalk
public async Task Stop()
{
_infoTimer?.Stop();
_stopHttpListener = true;
_httpListener?.Stop();
await _mqttClient?.StopAsync();
}
19
Source : ConnectionStats.cs
with MIT License
from bmresearch
with MIT License
from bmresearch
private void RemoveOutdatedData(object sender, ElapsedEventArgs e)
{
var currentSec = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
lock (this)
{
if (_historicData.ContainsKey(currentSec - 60))
{
_historicData.Remove(currentSec - 60);
}
if (_historicData.Count == 0)
{
_timer.Stop();
AverageThroughput60Seconds = 0;
AverageThroughput10Seconds = 0;
}
else
{
ulong total = 0, tenSecTotal = 0;
foreach (var kvp in _historicData)
{
total += kvp.Value;
if (kvp.Key > currentSec - 10)
{
tenSecTotal += kvp.Value;
}
}
AverageThroughput60Seconds = total / 60;
AverageThroughput10Seconds = tenSecTotal / 10;
}
}
}
19
Source : Debouncer.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (_paused == 0)
{
_triggered = false;
_timer.Stop();
_action();
}
}
19
Source : Debouncer.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
public void Pause()
{
lock (_timer)
{
_paused++;
_timer.Stop();
}
}
19
Source : Scheduler.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
public void Handle(ApplicationShutdownRequested message)
{
_logger.Info("Shutting down scheduler");
_cancellationTokenSource.Cancel(true);
Timer.Stop();
}
19
Source : ViewController.cs
with GNU General Public License v3.0
from boonkerz
with GNU General Public License v3.0
from boonkerz
private void ClientListener_onPeerConnected(object sender, EventArgs e)
{
SetLabelStatus("Connected");
connectionStatus.Stop();
//onlineCheckTimer.Start();
}
19
Source : MainForm.cs
with GNU General Public License v3.0
from boonkerz
with GNU General Public License v3.0
from boonkerz
private void ClientListener_onPeerConnected(object sender, EventArgs e)
{
this.lblStatus.Text = "Broker Connected";
connectionStatus.Stop();
//onlineCheckTimer.Start();
}
19
Source : RemoteForm.cs
with GNU General Public License v3.0
from boonkerz
with GNU General Public License v3.0
from boonkerz
private void RemoteForm_FormClosing(object sender, FormClosingEventArgs e)
{
onlineCheckTimer.Stop();
clientThread.Manager.sendMessage(new StopScreenSharingMessage { SymmetricKey = clientThread.Manager.getSymmetricKeyForRemoteId(this.SystemId), HostSystemId = this.SystemId, ClientSystemId = clientThread.Manager.SystemId });
}
19
Source : MainForm.cs
with GNU General Public License v3.0
from boonkerz
with GNU General Public License v3.0
from boonkerz
private void HostListener_onPeerConnected(object sender, EventArgs e)
{
this.lblStatus.Text = "Broker Connected";
connectionStatus.Stop();
}
19
Source : ViewController.cs
with GNU General Public License v3.0
from boonkerz
with GNU General Public License v3.0
from boonkerz
private void HostListener_onPeerConnected(object sender, EventArgs e)
{
SetLabelStatus("Connected");
connectionStatus.Stop();
}
19
Source : Service.cs
with GNU General Public License v3.0
from boonkerz
with GNU General Public License v3.0
from boonkerz
public void OnStop()
{
connectionStatus.Stop();
hostThread.Stop();
}
19
Source : Service.cs
with GNU General Public License v3.0
from boonkerz
with GNU General Public License v3.0
from boonkerz
private void HostListener_onPeerConnected(object sender, EventArgs e)
{
connectionStatus.Stop();
}
19
Source : Display.cs
with GNU General Public License v3.0
from boonkerz
with GNU General Public License v3.0
from boonkerz
public void StopScreenSharing(string clientSystemId)
{
if (this.ConnectedClients.Contains(new ClientLisreplacedem(clientSystemId)))
{
this.ConnectedClients.Remove(new ClientLisreplacedem(clientSystemId));
}
if(this.ConnectedClients.Count == 0) {
refreshThread.Stop();
}
}
19
Source : DiscoveryProtocolViewModel.cs
with GNU General Public License v3.0
from BornToBeRoot
with GNU General Public License v3.0
from BornToBeRoot
private void _discoveryProtocol_Complete(object sender, EventArgs e)
{
_remainingTimer.Stop();
IsCapturing = false;
}
19
Source : FormMain.cs
with MIT License
from breeswish
with MIT License
from breeswish
private void FsxController_FsxiConnected(object sender, EventArgs e)
{
log.Debug("Fsx FSUIPC connected");
timerFsxConnect.Stop();
}
See More Examples