How to count messages in the window message queue? - winapi

It seems that there's no a documented API to accomplish the subj, but maybe there's an undocumented one, or some trick to do this?

The only two counts you can get are "full" (something like PostMessage fails with the error ERROR_NOT_ENOUGH_QUOTA) and "empty" (PeekMessage returns zero).
If you need any other value, you're probably trying to solve the wrong problem.

Related

How do I use GET /channels/{channel.id}/messages

I want to make a bot to search through a channel and find a random message by a user. To do that, I need to read past messages. I've looked in the documentation and all it says is GET /channels/{channel.id}/messages.
I'm asking: How could I return the contents of a message and the author of the message (if possible).
If you're using discord.py, take a look at channel.history

Deleting message after using sendirect() on it in omnetpp

In my project I have the following code snippet
if(strcmp(msg->getName(),"failedAck") == 0 || ......)
{
msg->removeControlInfo();
msg->setControlInfo(info);
recvControls++;
sendDirect(msg, table, "ackIn");
}
Essentially the a message arrives at its final destination (lets call it A*), and if it is a type of specified messages, it is sent to another module (B*) which uses the information it carries to perform an operation.
The problem I am having is that after sending the message to the other B*, I delete the message after I am done using it. However, it still appears as part of A* when I look in the inspector. And when I try and delete the message in A* I get an error message saying can't delete the message because it is currently scheduled.
I can't figure out why this happens, Does this mean that sendDirect() does not change the ownership of the message (contrary to the manual)?
Help in this matter will be greatly appreciated, currently dealing with memory management issues in my simulation, and this is a part of it.
I would like to withdraw this question and say thanks to everyone who looked at it. I just recently discovered that the items were being deleted when they were supposed to be. however, i had forgotten that i was making a clone of the object for other uses, that why it was showing up in the inspector. My apologies.

Exchange Web Service error : "Resources are unavailable. Try again later., Cannot seek a row."

When I'm trying to get email items from Exchange (Office 365) using EWS.
I'm trying to do that by chunks with 500 messages. Sometimes, when I'm call method findItem I'm getting error : "Resources are unavailable. Try again later., Cannot seek a row."
Googling didn't provide anythings. I don't understand what does it mean and how to solve this.
Thanks
I can't say as I've run into this specific error before, but when dealing with O365, you'll often encounter these kinds of "go away, come back later" messages, and will have to implement a retry mechanism. Reducing your chunk size might help as well, but the message does contain your next step, i.e. "Try again later." Now if the request never succeeds after retry, this might be a deeper issue, but it does sound like a transient error from what you've described.
The email being retrieved is within a folder that may have too many items. Retrieving such items usually returns similar errors. Splitting the folder such that each folder holds a max of 70,000 items may help.

Promises without `.then`

Is there any downside to using a promise with only .catch section, but without .then at all?
I'm asking about the cases where the resolution result is not needed, only error handling.
Is this a good pattern to rely on .catch only and skip .then?
Or is it something that depends on which promise implementation it is?
Conceptually, there's nothing wrong with an operation that only has an error handler and has nothing else to do upon successful completion. If that's all it needs, then that's fine. For example, suppose you're updating a server with some new data from the client. If the data is successfully sent to the server, there's nothing else to do because the operation is complete, but if there's an error, then there is perhaps something else to do (retry, inform the user, correct the data based on the error code, etc...).
To comment on whether that's the right way to design your specific code, we'd have to see the actual code and understand what it is doing and then form an opinion on whether that is the best way to structure that specific code.
If I was designing a general purpose function, I'd certainly provide both completion (resolving the promise) and error (rejecting the promise) so the caller could hook into either one. But it is really up to the caller which events they want to know about and if only the error matters, then just having a .catch() is fine.

Functional Event Driven Programming

I'm having trouble writing event driven GUI code in a functional style, using Clojure and Seesaw. Specifically, I can't figure out how to pass the state of the program around without using globals, or some other unpleasant hack. My current approach is something like this:
(defn event-handler [gui-state event]
(update-gui! (get-new-state gui-state event)))
(defn update-gui! [gui-state]
(remove-all-listeners (gui-state :button))
(seesaw.core/listen (gui-state :button)
:action
(partial event-handler gui-state)))
It sets an event listener on the relevant component, with a partially applied function to advance the state and update the gui, including removing the old listener. Although this seems to be working, I don't really like it, partly because I can't pass the listener itself in the state (since it's not constructed until after I've already defined the state), so removing the old listener requires removing all listeners, which could cause problems as the program grows.
The closest solution I've found online is in this answer, but I don't know how to handle events as a stream like it shows. I'm sure there must be a better solution than my current approach, but I can't figure out what.
Can anyone show me how I can respond to user input events while still following a functional style?
The Streams from the linked answer seem like an analog of core.async channels.
Instead of removing all listeners each event maybe pass in a channel that has event details put to it. The same channel should go to the button's logic handler where it will repeatedly be taken from.

Resources