Clear variables on window close

I’m using

DynamicModule[{ var1, var2 },  CreateDialog[ (*some code here*) ]] 

In order to be able to deal with memory isolation for multiple copies of a program running at once. Is there an option to use in CreateDialog to run a command upon the closing of that Dialog? When that window gets closed I would like to clear all the variables to free up the memory.

Window handle is invalid

I’m trying to implement an input listener for FNA (modern version of XNA). Since FNA does not supply any sort of way to listen to native input this has to be done through the windows API and native calls. This is how I set this up:

public KeyboardListener(GameWindow window) {     var procedurePointer = Marshal.GetFunctionPointerForDelegate<WindowProcedure>(Procedure);     procedure = new IntPtr(SetWindowLongPtr(window.Handle, GWL_WNDPROC, procedurePointer.ToInt64()));     if (procedure == IntPtr.Zero)     {         var error = GetLastError();         throw error switch         {             ERROR_INVALID_WINDOW_HANDLE => new InvalidOperationException("Invalid window handle"),             _ => new InvalidOperationException($  "Unknown error message '0x{error:X4}'")         };     } }  // private const int GWL_WNDPROC = -4;  // [DllImport("user32.dll", CharSet = CharSet.Unicode)] private static extern int SetWindowLongPtr(IntPtr hWnd, int nIndex, long dwNewLong);  [DllImport("Kernel32.dll", CharSet = CharSet.Unicode)] private static extern uint GetLastError(); 

I construct the keyboard listener during the Initialize method of Game:

class MyGame : Game {     protected override void Initialize() {         new KeyboardListener(Window);     } } 

This is the method call that reports the error: SetWindowLongPtr(window.Handle, GWL_WNDPROC, procedurePointer.ToInt64()) and it throws "Invalid window handle". It’s worth noting that the example code I saw converted the pointers to Int32 instead of Int64, but I am on a 64 bit machine so the pointers can not fit in 32 bits.

What I’ve tried & figured out so far…

  • Debugging tells me that both window.Handle and procedurePointer are non-null and at least point to something.
  • I have tried to initialize it earlier or later, but that doesn’t seem to make a difference.
  • Other native methods such as SDL2.SDL.SDL_MinimizeWindow(Window.Handle) work perfectly fine and don’t complain about the window handle.

Default Game Window Size To Take While Making Games

I am planning to make a game for mobiles and tablets, I wanted to know what would be the default resolution that I should set for my game so that it covers all or most of the devices out there.
I read an article someplace that says we should design the game for lowest resolution like 480 x 360 and then scale it according to devicePixelRatio for the target device, Is this the right approach because according to me it will be good only for devices that have 3:2 resolution but what about other 16:9, 16:10 etc
So What should be the base resolution I design my game so that it gets scaled to all mobiles and tablets

How to Find the Latest Window Apps

What types of Android Apps are there that will really impress the customers? There are many options that you can choose from. Here are some of the popular ones:

Navigation Apps: This is easy access to your profile, browsing history, email accounts, and more. These are the main reasons why people love using these. The navigation is made more convenient with the help of some new features such as instant search, and social integration.

Phone Control Apps: If you are a budding entrepreneur who wants to develop an app that is entirely about managing your phone, then a Phone Control App is what you need. Some features include the ability to control all the functions of your phone with the right app installed on your device. You can be sure that your business will benefit greatly from using these. You are curious to know more about antivirus, read this.

Mobile Messaging Apps: When the mobile industry was just starting out, people were initially too apprehensive of having their messages leaked on the market. With today’s technologies, you can now stay connected with your friends and business associates from any part of the world. It is very important to have an app that will allow you to get in touch with your loved ones as soon as possible.

enter image description here

Full-Featured Games: Are you tired of playing Angry Birds, Facebook, and other similar apps that are available for free? Why not try to develop a full-featured game and create a platform that will give you and your users something truly unique. With the right kind of graphics and sound effects, your game will definitely win over the competition.

One Top Paid Applications: When you want to create your own business, a high-end application is what you need. However, it is hard to develop such applications on your own. You need a developer, and this is where an expert can help you develop a useful and a high-tech application.

If you have an idea on how to make your Android application the best one, all you need to do is to hire a mobile developer to handle your task. However, you must make sure that you get in touch with the right developer. who will provide you with the best possible products and applications?

What happens if a sender changes the TCP window size over multiple packets that have the same ACK number?

I’m currently doing research on evasion attacks that seek to bypass a Deep-learning based Network Intrusion Detection System.

In order to achieve this, I need to know what the constraints are for the TCP window size field in the TCP packet header. Imagine a client has just sent the last TCP-ACK packet to a server in order to complete the 3-way handshake. He then immediately proceeds to send a GET request to the server (these 2 packets are thus sent one after the other, and contain the same ACK-number).

What happens if the TCP window size in the TCP-ACK packet does not match the window size in the TCP packet containing the GET request? Will the receiver simply observe the last value for the window size that he obtained? Or will there be a violation in the TCP protocol in any way? You can assume that the change in window size is very small, and will not cause the buffer to be full.

More generally, if the client sends N uninterrupted packets (e.g. a heavy-load POST request), can he change the window size in each packet header without repercussions?

Should OAuth2 proprietary client authorization prompt a confirmation window?

Given a company named X.

X has an OAuth 2 API available for its proprietary clients and also for 3rd party clients.

When a user P enters the process of authorizing a client, it is prompted with a window (right after authentication) showing several information (such as the application name, the scopes required, etc…) and must either click “confirm” or “cancel” to continue the process.

While having the user being able to confirm/deny authorization requests from 3rd party clients makes senses, does it still make sense to show this confirmation window for X‘s proprietary clients?

  • Is there something in the standard that forces to have this confirmation for every authorization request?
  • Is there a best practice in regards of that, that everyone agrees to?

Simplifying Function with Recursive CTE and/or Window Function

I’m trying to come up with a Recursive CTE and/or Window Function to create a function.

After days, I’ve boiled the function down to (pseudocode) where I have N and B, and need to generate E:

En = Bn * (1 – SUM(E1, E2, … En-1))


╔═══╦═════════════╦═════════════╗ ║ N ║ B           ║ E           ║ ╠═══╬═════════════╬═════════════╣ ║ 0 ║ 0.142857143 ║ 0.142857143 ║ ║ 1 ║ 0.285714286 ║ 0.244897959 ║ ║ 2 ║ 0.285714286 ║ 0.174927114 ║ ║ 3 ║ 0.285714286 ║ 0.124947938 ║ ║ 4 ║ 0.285714286 ║ 0.089248527 ║ ║ 5 ║ 0.4         ║ 0.089248527 ║ ║ 6 ║ 0.666666667 ║ 0.089248527 ║ ║ 7 ║ 1           ║ 0.044624264 ║ ╚═══╩═════════════╩═════════════╝ 

E0 = 0.143 * (1 – 0) = 0.143
E1 = 0.286 * (1 – 0.143) = 0.245
E2 = 0.286 * (1 – (0.143 + 0.245)) = 0.175
E3 = 0.286 * (1 – (0.143 + 0.245 + 0.175)) = 0.125
E4 = 0.286 * (1 – (0.143 + 0.245 + 0.175 + 0.125)) = 0.089
E5 = 0.400 * (1 – (0.143 + 0.245 + 0.175 + 0.125 + 0.089)) = 0.089
E6 = 0.667 * (1 – (0.143 + 0.245 + 0.175 + 0.125 + 0.089 + 0.089)) = 0.089
E7 = 1.000 * (1 – (0.143 + 0.245 + 0.175 + 0.125 + 0.089 + 0.089 + 0.089)) = 0.044

If the table above was in Excel, C2 = B2 * (1 - 0) (base) and C3 = B3 * (1 - SUM(C$ 2:C2)) (recursive)

What I’ve tried:

Windowed Functions

Tried SUM(...) OVER(ORDER BY [N] ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), but can’t reference the column recursively.

Recursive CTE

Tried several iterations of:

WITH B AS ([Num], [Best], [Effective Rate]) AS (     SELECT *         , [Best]     FROM A     WHERE [Num] = 0     UNION ALL     SELECT A.*         , (1 - [Effective Rate]) * A.[Best]     FROM B     JOIN A ON A.[Num] = B.[Num] + 1  ) 

and some with an extra column in the CTE, but it only covers 1 previous row and results after 2nd row are wrong.

Recursive CTE with Windowed Function

From all that I’ve tried, it seems that the recursive segment of the CTE is calculated independently of the other results, and SUM(...) OVER(...) only works on the current row. (With regard to the above table, all values of E would be 0.142857143).

I assume this is because the UNION ALL happens all at once, and not incrementally.

Alternative Solutions

What I would really like to happen is to simplify the above equation, and/or transform it into an iterative function.

Bonus: If anyone cares to know the source of this information, it’s used to calculate MACRS depreciation for tax purposes.

Duplicating ACKs and Window Sizes

After reading an answer at this link:

I am confused. Do ACK values repeat when a packet is lost or when an out of sequence packet is received? For example in the diagram, the ACK values are same at the 12th and 13th segment. However, there’s a drastic change in the window size. What exactly is the link? enter image description here