Skip to content

Commit

Permalink
Misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Jun 15, 2015
1 parent b4e9226 commit d2bf455
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions MygodWifiShare/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ private static void Boot()
Close();
return;
}
WriteReason(reason = key is string ? WlanManager.SetSecondaryKey((string) key)
: WlanManager.SetSecondaryKey((byte[]) key));
var keyString = key as string;
WriteReason(reason = keyString != null ? WlanManager.SetSecondaryKey(keyString)
: WlanManager.SetSecondaryKey((byte[]) key));
if (reason != WlanHostedNetworkReason.Success)
{
Close();
Expand Down Expand Up @@ -459,16 +460,16 @@ private static void ShowStatus()
});
}

private static bool requireUpdate = true;
private static DateTime lookupTime = DateTime.MinValue;
private static ILookup<string, Arp.MibIpNetRow> lookup;
public static ILookup<string, Arp.MibIpNetRow> Lookup
{
get
{
if (requireUpdate)
if ((DateTime.Now - lookupTime).TotalSeconds > Ttl)
{
lookup = Arp.GetIpNetTable().ToLookup(row => row.MacAddress, row => row);
requireUpdate = false;
lookupTime = DateTime.Now;
}
return lookup;
}
Expand All @@ -486,7 +487,7 @@ public static string GetDeviceDetails(WlanHostedNetworkPeerState peer, bool wait
var domains = DnsCache.GetDomains(ip.IPAddress, wait || Ttl == 0);
return ip.ToString() + (domains == null ? string.Empty : (" [" + domains + ']'));
})));
else requireUpdate = true;
else lookupTime = DateTime.MinValue;
return result;
}
private static string QueryCurrentDevices(bool wait = false)
Expand Down Expand Up @@ -524,7 +525,7 @@ private static void WatchCurrentDevices()
Console.Clear();
Console.WriteLine("监视已连接设备中,按 Esc 键返回。");
Console.WriteLine(result);
Thread.Sleep(500);
Thread.Sleep(1000);
}
Console.Clear();
}
Expand Down
4 changes: 2 additions & 2 deletions MygodWifiShare/[References]/[TaskScheduler]/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,11 +1239,11 @@ public DateTime[] GetRunTimes(DateTime start, DateTime end, uint count = 0)
count = count1;
}
ret = new DateTime[count];
int stSize = Marshal.SizeOf(typeof(TaskScheduler.V1Interop.SystemTime));
int stSize = Marshal.SizeOf(typeof(V1Interop.SystemTime));
for (int i = 0; i < count; i++)
{
st = new IntPtr(runTimes.ToInt64() + (i * stSize));
ret[i] = (TaskScheduler.V1Interop.SystemTime)Marshal.PtrToStructure(st, typeof(TaskScheduler.V1Interop.SystemTime));
ret[i] = Marshal.PtrToStructure<V1Interop.SystemTime>(st);
}
}
catch (Exception ex)
Expand Down

0 comments on commit d2bf455

Please sign in to comment.