message

How to post a UI message from a worker thread in C#

家住魔仙堡 提交于 2019-12-04 17:17:57
I'm writing a simple winforms app in C#. I create a worker thread and I want the main window to respond to the tread finishing its work--just change some text in a text field, testField.Text = "Ready". I tried events and callbacks, but they all execute in the context of the calling thread and you can't do UI from a worker thread. I know how to do it in C/C++: call PostMessage from the worker thread. I assume I could just call Windows API from C#, but isn't there a more .NET specific solution? Matt Davis In the event callback from the completed thread, use the InvokeRequired pattern, as

Unread message count in a PHP app

£可爱£侵袭症+ 提交于 2019-12-04 17:04:12
I am currently developing a simple PHP application where users can send messages to each other. Messages are stored in a SQL database. I'd like to put a count of unread messages in the menu on every page, so that a user can see quickly if they have new messages without checking the inbox periodically. While this may be an easy problem to solve, I don't know what the best method would be, performance-wise : Do a plain SQL COUNT() of unread messages on every page load (instantly notified of changes, but it may impact performance badly ?) Do the same thing, but cache the result for X minutes (we

Spring注解之@RestControllerAdvice

徘徊边缘 提交于 2019-12-04 16:30:41
前言 前段时间部门搭建新系统,需要出异常后统一接口的返回格式,于是用到了Spring的注解@RestControllerAdvice。现在把此注解的用法总结一下。 用法 首先定义返回对象ResponseDto 1 package com.staff.points.common; 2 3 import lombok.Data; 4 5 import java.io.Serializable; 6 7 @Data 8 public class ResponseDto<T> implements Serializable { 9 private static final long serialVersionUID = -284719732991678911L; 10 11 private String code; 12 13 private String message; 14 15 private T data; 16 17 public static <T> ResponseDto<T> assemblingSuccessResponse(T data) { 18 ResponseDto<T> responseDto = new ResponseDto<>(); 19 responseDto.setCode(ResponseCodeEnum.SUCCESS.getCode());

how to send a notification a user received a private message

拥有回忆 提交于 2019-12-04 14:36:36
i created a messaging model where a user can send a private message to another user. however im not sure how to go about notifying the user he/she got a new message. does anyone have a way to go about doing this? or if there was a simple solution? def create @message = current_user.messages.build @message.to_id = params[:message][:to_id] @message.user_id = current_user.id @message.content = params[:message][:content] if @message.save flash[:success ] = "Private Message Sent" end redirect_to user_path(params[:message][:to_id]) end i can tell the sender that a private message was sent, but im

What happens to pending messages for a window that has been destroyed?

拈花ヽ惹草 提交于 2019-12-04 12:54:30
What happens when a window is destroyed while there are still messages pending for it? Consider the following scenario: There are three threads, A, B, and C. Thread C owns a window. Threads A and B use SendMessage to post messages to the window. The message from A arrives first. While C is processing the message from A, it destroys its window using DestroyWindow . What happens to the message from thread B? Does the call by thread B to SendMessage return? How does this work internally? According to MSDN , DestroyWindow "[...], flushes the thread message queue, [...]". I was not sure whether

Erlang: remote call vs sending messages

北战南征 提交于 2019-12-04 12:14:02
问题 I'd like to execute some procedure on a remote node. And I'm not sure which is the best way to do this. I can write a rpc:call to do this. Or send a message by Remote ! {call, some_procedure} to the node to start the procedure and use receive waiting for the response. So which way is better in erlang? Or they actually are for different usage? 回答1: It's better to use module rpc , because if you don't: you'll have to manage monitoring of remote node, have to provide unique id of the call,

Django How to implement alert()(popup message) after complete method in view

穿精又带淫゛_ 提交于 2019-12-04 10:57:27
问题 I would like to have an alert() message (like in javascript) after method in view.py is complete My method is def change_password(request): dictData = getInitialVariable(request) in_username = request.POST['txt_username'] in_password = request.POST['txt_password'] in_new_password = request.POST['txt_new_password'] user = authenticate(username=in_username, password=in_password) if user is not None: if user.is_active: u = User.objects.get(username=in_username) u.set_password(in_new_password) u

How do I raise the same Exception with a custom message in Python?

情到浓时终转凉″ 提交于 2019-12-04 07:21:32
问题 I have this try block in my code: try: do_something_that_might_raise_an_exception() except ValueError as err: errmsg = 'My custom error message.' raise ValueError(errmsg) Strictly speaking, I am actually raising another ValueError , not the ValueError thrown by do_something...() , which is referred to as err in this case. How do I attach a custom message to err ? I try the following code but fails due to err , a ValueError instance , not being callable: try: do_something_that_might_raise_an

What does <h:messages> do in JSF?

烈酒焚心 提交于 2019-12-04 06:06:37
I am learning JSF and came across this line: <h:messages layout="table"></h:messages> in a sample application ? Am not sure what does this line do? I get no error when removing the line from the code, and am able to run it and get the same output ? sven The h:messages tag renders all messages for the current JSF view which are not covered by a h:message (remark the missing 's' at the end) tag. Messages can be generated explicitly by your backing beans ( FacesContext.addMessage ) or implicitly by JSF. E.g. if you have marked an input value as required and the user submits the form without

Count unreaded Number of missed call and message in Windows phone

落爺英雄遲暮 提交于 2019-12-04 05:51:05
问题 How to display badge of unread message and call in windows phone 8 application? I want display notification count in my application icon when I open application at that time it will remove like call and message application. I know the tile notification but i don't know how remove badge when I open application Note: how to send and receive toast notification with badge 回答1: I got the solution... Handle tile pragmatically in windows phone. ShellTile tile = ShellTile.ActiveTiles.First(); if