private void MyTimerCallback(object state) { if (state == this.cookie) { if (!this.autoReset) { this.enabled = false; } FILE_TIME lpSystemTimeAsFileTime = new FILE_TIME(); GetSystemTimeAsFileTime(ref lpSystemTimeAsFileTime); ElapsedEventArgs e = new ElapsedEventArgs(lpSystemTimeAsFileTime.ftTimeLow, lpSystemTimeAsFileTime.ftTimeHigh); try { ElapsedEventHandler onIntervalElapsed = this.onIntervalElapsed; if (onIntervalElapsed != null) { if ((this.SynchronizingObject != null) && this.SynchronizingObject.InvokeRequired) { this.SynchronizingObject.BeginInvoke(onIntervalElapsed, new object[] { this, e }); } else { onIntervalElapsed(this, e); } } } catch { } } }
private void MyTimerCallback(object state) { lock (statusChangeLockObject) { try { if (enabled && !isOccupied) { isOccupied = true; isWorking = true; FILE_TIME fileTime = new FILE_TIME(); SafeNativeMethods.GetSystemTimeAsFileTime(ref fileTime); workHandler.BeginInvoke(this, new DoScheduledWorkEventArgs(Argument, DateTime.FromFileTime((long)((((ulong)fileTime.ftTimeHigh) << 32) | (((ulong)fileTime.ftTimeLow) & 0xffffffff)))), null, null); } } catch (Exception ex) { timerException = ex; } } }
internal void PopulateFrom(ref WIN32_FIND_DATA findData) { dwFileAttributes = (int)findData.dwFileAttributes; ftCreationTime = findData.ftCreationTime; ftLastAccessTime = findData.ftLastAccessTime; ftLastWriteTime = findData.ftLastWriteTime; nFileSizeHigh = findData.nFileSizeHigh; nFileSizeLow = findData.nFileSizeLow; }
private void MyTimerCallback(object state) { lock (statusChangeLockObject) { if (enabled && !isOccupied) { isOccupied = true; isWorking = true; mainThreadContext = mainThreadOperation.SynchronizationContext.CreateCopy(); FILE_TIME fileTime = new FILE_TIME(); SafeNativeMethods.GetSystemTimeAsFileTime(ref fileTime); DateTime time = DateTime.FromFileTime((long)((((ulong)fileTime.ftTimeHigh) << 32) | (((ulong)fileTime.ftTimeLow) & 0xffffffff))); workHandler.BeginInvoke(this, new DoScheduledWorkEventArgs(Argument, time), null, null); } } }
private void MyTimerCallback(object state) { // System.Threading.Timer will not cancel the work item queued before the timer is stopped. // We don't want to handle the callback after a timer is stopped. if (state != cookie) { return; } if (!this.autoReset) { enabled = false; } #if MONO ElapsedEventArgs elapsedEventArgs = new ElapsedEventArgs(DateTime.Now); #else FILE_TIME filetime = new FILE_TIME(); GetSystemTimeAsFileTime(ref filetime); ElapsedEventArgs elapsedEventArgs = new ElapsedEventArgs(filetime.ftTimeLow, filetime.ftTimeHigh); #endif try { // To avoid ---- between remove handler and raising the event ElapsedEventHandler intervalElapsed = this.onIntervalElapsed; if (intervalElapsed != null) { if (this.SynchronizingObject != null && this.SynchronizingObject.InvokeRequired) { this.SynchronizingObject.BeginInvoke(intervalElapsed, new object[] { this, elapsedEventArgs }); } else { intervalElapsed(this, elapsedEventArgs); } } } catch { } }
internal static extern void GetSystemTimeAsFileTime(ref FILE_TIME lpSystemTimeAsFileTime);
internal unsafe static extern bool SetFileTime(SafeFileHandle hFile, FILE_TIME* creationTime, FILE_TIME* lastAccessTime, FILE_TIME* lastWriteTime);
private void seedMarketBtn_Click(object sender, EventArgs e) { // Create Selected Races for SQL query: string Selectedraces = ""; foreach (ListViewItem Selected in marketRacesTxtBox.SelectedItems) { Selectedraces = Selectedraces + ", '" + Selected.SubItems[1].Text + "'"; } if (Selectedraces != ("")) { Selectedraces = Selectedraces.Remove(0, 2); } else { Selectedraces = "0"; } // Create Selected Groups for SQL query: string Selectedgroups = ""; foreach (ListViewItem Selected in marketGroupsTxtBox.SelectedItems) { Selectedgroups = Selectedgroups + ", '" + Selected.SubItems[1].Text + "'"; } if (Selectedgroups != ("")) { Selectedgroups = Selectedgroups.Remove(0, 2); } else { Selectedgroups = "''"; } // Create Selected Systems for SQL query: CultureInfo culture = new CultureInfo("en-US"); string Selectedsystems = ""; long fullIndex = 0; float index = 0; float divisor = ((float)100.0) / ((float)(trackBar1.Value)); index += divisor; foreach (ListViewItem Selected in marketSystemsTxtBox.SelectedItems) { ++fullIndex; if (((long)index) == fullIndex) { if (((System.Convert.ToSingle(Selected.SubItems[2].Text, culture) >= System.Convert.ToSingle(marketSecurityTxtBox.Text, culture)) && (radioButton3.Checked)) || ((System.Convert.ToSingle(Selected.SubItems[2].Text, culture) <= System.Convert.ToSingle(marketSecurityTxtBox.Text, culture)) && (radioButton4.Checked))) { Selectedsystems = Selectedsystems + ", '" + Selected.SubItems[1].Text + "'"; } index += divisor; } } if (Selectedsystems != ("")) { Selectedsystems = Selectedsystems.Remove(0, 2); } else { Selectedsystems = "''"; } // Create Selected Systems for SQL query from Selected Regions: --- THIS OVERRIDES WHATEVER SELECTED SYSTEMS DETERMINED ABOVE --- string Selectedregions = ""; foreach (ListViewItem Selected in marketRegionsTxtBox.SelectedItems) { Selectedregions = Selectedregions + ", '" + Selected.SubItems[1].Text + "'"; } if (Selectedregions != ("")) { Selectedregions = Selectedregions.Remove(0, 2); Selectedsystems = ""; fullIndex = 0; index = 0; divisor = ((float)100.0) / ((float)(trackBar1.Value)); index += divisor; foreach (DataRow record in DBConnect.AQuery("SELECT solarSystemID, security FROM mapSolarSystems WHERE regionid IN (" + Selectedregions + ")").Rows) { ++fullIndex; if (((long)index) == fullIndex) { if (((System.Convert.ToSingle(record[1].ToString(), culture) >= System.Convert.ToSingle(marketSecurityTxtBox.Text, culture)) && (radioButton3.Checked)) || ((System.Convert.ToSingle(record[1].ToString(), culture) <= System.Convert.ToSingle(marketSecurityTxtBox.Text, culture)) && (radioButton4.Checked))) { Selectedsystems = Selectedsystems + ", '" + record[0].ToString() + "'"; } index += divisor; } } if (Selectedsystems != ("")) { Selectedsystems = Selectedsystems.Remove(0, 2); } else { Selectedsystems = "''"; } } else { Selectedregions = "''"; } long bid = 0; if (radioButton1.Checked) // Make this query full of Sell Orders bid = 0; else { if (radioButton2.Checked) // Make this query full of Buy Orders bid = 1; else bid = 0; // If execution reaches this line, there is some problem with radioButton1 and radioButton2 interaction. } FILE_TIME ft1 = new FILE_TIME(); GetSystemTimeAsFileTime(ref ft1); UInt64 integerTime = (((UInt64)(ft1.dwHighDateTime)) << 32) | ((UInt64)(ft1.dwLowDateTime)); string str_MySQL_Query; if (Selectedraces != "NULL") { str_MySQL_Query = "INSERT INTO market_orders (typeID, charID, regionID, stationID, bid, price, volEntered, volRemaining, issued, orderState, minVolume, contraband, accountID, duration, isCorp, solarSystemID, escrow, jumps) SELECT typeID, 1 as charID, regionID, stationID, " + bid.ToString() + " as bid, basePrice as price, " + marketQuantityTxtBox.Text + " as volEntered, " + marketQuantityTxtBox.Text + " as volRemaining, " + integerTime.ToString() + " as issued, 1 as orderState, 1 as minVolume,0 as contraband, 0 as accountID, 18250 as duration,0 as isCorp, solarSystemID, 0 as escrow, 1 as jumps FROM staStations, invTypes WHERE solarSystemID in (" + Selectedsystems + ") AND published = 1 and raceID in (" + Selectedraces + ") and groupID in (" + Selectedgroups + ")"; queryMarketSeedTxtBox.Text = str_MySQL_Query; if (applyQueryToDBChkBox.Checked) DBConnect.SQuery(str_MySQL_Query); } else { str_MySQL_Query = "INSERT INTO market_orders (typeID, charID, regionID, stationID, bid, price, volEntered, volRemaining, issued, orderState, minVolume, contraband, accountID, duration, isCorp, solarSystemID, escrow, jumps) SELECT typeID, 1 as charID, regionID, stationID, " + bid.ToString() + " as bid, basePrice as price, " + marketQuantityTxtBox.Text + " as volEntered, " + marketQuantityTxtBox.Text + " as volRemaining, " + integerTime.ToString() + " as issued, 1 as orderState, 1 as minVolume,0 as contraband, 0 as accountID, 18250 as duration,0 as isCorp, solarSystemID, 0 as escrow, 1 as jumps FROM staStations, invTypes WHERE solarSystemID in (" + Selectedsystems + ") AND published = 1 and raceID is NULL and groupID in (" + Selectedgroups + ")"; queryMarketSeedTxtBox.Text = str_MySQL_Query; if (applyQueryToDBChkBox.Checked) DBConnect.SQuery(str_MySQL_Query); } }
public static extern void GetSystemTimeAsFileTime(ref FILE_TIME lpSystemTimeAsFileTime);
private void MyTimerCallback(object state) { // System.Threading.Timer will not cancel the work item queued before the timer is stopped. // We don't want to handle the callback after a timer is stopped. if( state != cookie) { return; } if (!this.autoReset) { enabled = false; } #if MONO ElapsedEventArgs elapsedEventArgs = new ElapsedEventArgs(DateTime.Now); #else FILE_TIME filetime = new FILE_TIME(); GetSystemTimeAsFileTime(ref filetime); ElapsedEventArgs elapsedEventArgs = new ElapsedEventArgs(filetime.ftTimeLow, filetime.ftTimeHigh); #endif try { // To avoid ---- between remove handler and raising the event ElapsedEventHandler intervalElapsed = this.onIntervalElapsed; if (intervalElapsed != null) { if (this.SynchronizingObject != null && this.SynchronizingObject.InvokeRequired) this.SynchronizingObject.BeginInvoke(intervalElapsed, new object[]{this, elapsedEventArgs}); else intervalElapsed(this, elapsedEventArgs); } } catch { } }
internal unsafe static extern bool SetFileTime(IntPtr hFile, FILE_TIME* creationTime, FILE_TIME* lastAccessTime, FILE_TIME* lastWriteTime);
private void MyTimerCallback(object state) { if (state == this.cookie) { if (!this.autoReset) { this.enabled = false; } FILE_TIME lpSystemTimeAsFileTime = new FILE_TIME(); GetSystemTimeAsFileTime(ref lpSystemTimeAsFileTime); ElapsedEventArgs e = new ElapsedEventArgs(lpSystemTimeAsFileTime.ftTimeLow, lpSystemTimeAsFileTime.ftTimeHigh); try { ElapsedEventHandler onIntervalElapsed = this.onIntervalElapsed; if (onIntervalElapsed != null) { if ((this.SynchronizingObject != null) && this.SynchronizingObject.InvokeRequired) { this.SynchronizingObject.BeginInvoke(onIntervalElapsed, new object[] { this, e }); } else { onIntervalElapsed(this, e); } } } catch { } } }