|
how is it possible? would you please help me on this?
modified 13-Feb-19 21:02pm.
|
|
|
|
|
Please can anyone help with a project I'm working on. I'm trying to create a way of running an Azure message queue receiver in a permanently running background thread which immediately updates controls on a WPF page when a new message comes in. I've been playing with examples found on the web which download messages and display them in a console window but I'm struggling to work out how to pass the received messages over to a textbox control on an WPF page.
This is what I have been playing with which seems to work perfectly.....
namespace AzureMessagingReceiver
{
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.ServiceBus;
class Program
{
const string ServiceBusConnectionString = "######.......";
const string QueueName = "#####......";
static IQueueClient queueClient;
static void Main(string[] args)
{
MainAsync().GetAwaiter().GetResult();
}
static async Task MainAsync()
{
queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
Console.WriteLine("======================================================");
Console.WriteLine("Press ENTER key to exit after receiving all the messages.");
Console.WriteLine("======================================================");
RegisterOnMessageHandlerAndReceiveMessages();
Console.ReadKey();
await queueClient.CloseAsync();
}
static void RegisterOnMessageHandlerAndReceiveMessages()
{
var messageHandlerOptions = new MessageHandlerOptions(ExceptionReceivedHandler)
{
MaxConcurrentCalls = 1,
AutoComplete = false
};
queueClient.RegisterMessageHandler(ProcessMessagesAsync, messageHandlerOptions);
}
static async Task ProcessMessagesAsync(Message message, CancellationToken token)
{
Console.WriteLine($"Received message: SequenceNumber:{message.SystemProperties.SequenceNumber} Body:{Encoding.UTF8.GetString(message.Body)}");
await queueClient.CompleteAsync(message.SystemProperties.LockToken);
}
static Task ExceptionReceivedHandler(ExceptionReceivedEventArgs exceptionReceivedEventArgs)
{
Console.WriteLine($"Message handler encountered an exception {exceptionReceivedEventArgs.Exception}.");
var context = exceptionReceivedEventArgs.ExceptionReceivedContext;
Console.WriteLine("Exception context for troubleshooting:");
Console.WriteLine($"- Endpoint: {context.Endpoint}");
Console.WriteLine($"- Entity Path: {context.EntityPath}");
Console.WriteLine($"- Executing Action: {context.Action}");
return Task.CompletedTask;
}
}
}
.....just need help with how to turn this into what I need.
Any assistance greatly appreciated!
|
|
|
|
|
WPF relies heavily on INotifyPropertyChanged. You can use this to your advantage so that, when your data changes, you simply raise a PropertyChanged event.
This space for rent
|
|
|
|
|
1) Add messages received to a concurrent queue
2) When adding, start a "queue worker" if not already started
3) Queue worker dequeues messages and updates WPF window in progress reporting event
4) Queue worker runs until queue is empty,
or
1) Use a dispatcher timer to poll for new messages while updating WPF UI on same thread
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hello All,
Using toggleClass and hasClass in javascript to toggle between 'SelectAll' and 'DeselectAll', to control the checkboxes. 'SelectAll' would check all the checkboxes, and 'DeselectAll' would deselect them all at once. This works fine in my development environment, but in staging server, the button does not invoke any action. It does nothing.
How does one go about debugging another environment, which does not have VS installed?
I have pasted a snippet - thank you!
script type="text/javascript">
$(function () {
$("#SelectAll").click(function () {
var $this = $(this);
$this.toggleClass('SelectAll');
if ($this.hasClass('SelectAll')) {
$this.text('DeselectAll');
$this.val('DeselectAll');
var ischecked = true;
} else {
$this.text('SelectAll');
$this.val('SelectAll');
var ischecked = false;
}
});
});
</script>
|
|
|
|
|
There is a subtle clue in that code as to why this is the wrong forum. It's hidden in two places; the first being that this forum is for C# and the second is in you code when it says javascript. You might have more luck if you don't just randomly pick a forum.
This space for rent
|
|
|
|
|
This is an MVC solution, but i shall post this in the javascript forum.
Thank you.
|
|
|
|
|
Lots of "magic words" ... Is this typical of javascript? Makes it harder to debug / cross-reference.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Gerry Schmitz wrote: Is this typical of javascript? JQuery. Modern JavaScript is bundled with 10Mb worth of libraries and dependencies
That's to make things easier, I been told
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
using Newtonsoft.Json;
using System;
using System.Windows.Forms;
using System.Xml;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(" <student>\r\n <student_name>Preethi\r\n <ssn>45679\r\n <course>Electronics and communication\r\n <address>\r\n <line_1>#1, 6th cross\r\n <line_2>Victoria Layout\r\n <city>Bangalore\r\n <country>India\r\n </address>\r\n \r\n");
string jsonText = JsonConvert.SerializeXmlNode(doc);
MessageBox.Show(jsonText);
}
}
}
|
|
|
|
|
XmlDocument.Load Method[^]
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\Path\To\The\Xml\file.xml");
NB: You shouldn't try to put the whole question in the "subject" box. Instead, put a brief summary of the question as the subject, and type the detail of the question in the "message" box.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That XML is malformed. It seems you're missing closing tags all over the place.
<student>
<student_name>Preethi</student_name>
<ssn>45679</ssn>
<course>Electronics and communication</course>
<address>
<line_1>#1, 6th cross</line_1>
<line_2>Victoria Layout</line_2>
<city>Bangalore</city>
<country>India</country>
</address>
</student>
|
|
|
|
|
hello
right now i have a program class
have this list
List<order> lsor = new List<order>();
i want to access list lsor from another class
|
|
|
|
|
You don't. That would mean your other class would have to know about your Program class. That's a big encapsulation and separation of concerns no-no.
Your list should not be in the Program class. It should be in another class that maintains the list and exposes methods to manipulate it.
Then, you access the list in that class from the Program class, not the other way around.
|
|
|
|
|
Add a method to the "other class" that accepts a List<order> object as a parameter.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Hello
So recently i've been making a program that uses DllExport of "user32.dll". The program itself is running pretty ok but this warning always pops up.
Because it is a P/Invoke method, 'Form1.mouse_event(uint)' should be defined in a class named NativeMethods, SafeNativeMethods, or UnsafeNativeMethods
I tried already many times and watched a lot of examples but it didnt help me.
Here is the part of the code
namespace XXX
{
public partial class Form1 : Form
{
[DllImport ("user32.dll")]
static extern void mouse_event(uint dwFlags);
public Form1()
{
InitializeComponent();
}
private void keyPressAction(object sender, KeyEventArgs e)
{
e.SuppressKeyPress = true;
System.Threading.Thread.Sleep(300);
Cursor.Position = new System.Drawing.Point(1000, 0);
mouse_event(0x002 | 0x004);
DC
|
|
|
|
|
It's just a warning that there is a convention for moving all P/Invoke calls into a class called one of the three listed there. While it's recommended practice, it's not actually going to cause a bug in your code that it's not in one of those classes. Pragmatically speaking, you can safely ignore this warning. What I would be more concerned with, if I were you, is the fact that your keyPressAction is going to block the UI thread for 300 milliseconds. That's a major design flaw.
This space for rent
|
|
|
|
|
Maybe he really hates fast typists?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
This space for rent
|
|
|
|
|
Thank you
|
|
|
|
|
and blocking UI thread.... is a part of my plan
|
|
|
|
|
Your plan is to piss off your users?
This space for rent
|
|
|
|
|
|
Then - not to put too fine a point on it - you are an idiot.
You will annoy people and make them work hard to ensure that you have no access to their machine(s) again. If you could install this, what else might you install?
If you are in a corporate environment, you could end up with a dressing down, disciplinary action, possibly being fired. If these are your mates, then they won't trust you as much again.
You can do it, but we won't help: technically it's malware and we do not condone, support, or assist in the production of malicious code in any way, form, or manner. This is a professional site for professional developers.
If you want to know how to create such things, you need to visit a hacking site: but be sure to disable all firewalls and antivirus products first or they won't trust you enough to tell you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Then - not to put too fine a point on it - you are an idiot.
I did the same, years ago. Some coworker wondered why his CD-tray kept opening and closing on its own[^] while he was working. It's hard not to burst from laughing if someone looks for an exorcist.
OriginalGriff wrote:
If you are in a corporate environment, you could end up with a dressing down, disciplinary action, possibly being fired. Any corporate environment says that you should lock your PC if you leave the station. If you don't, then don't blame me for using the keyboard for reminding you of company-policy.
OriginalGriff wrote: If you want to know how to create such things, you need to visit a hacking site: Gag-applications are a very long way from hacking, and his source doesn't look like something to hijack a computer. Remember this one[^]? I'll bet you recognize it when you hover the link
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|