我是非常新的XML使用C#我有一个XML我需要通过父亲中的特定子项我需要获取id和调用变量变量我这样做但每次都没有通过循环
我需要通过xml的所有父项,直到我得到我想要的树吗?
xml
<message xmlns="jabber:client" to="1072@finesse1.dcloud.cisco.com" id="/finesse/api/User/1072/Dialogs__1072@finesse1.dcloud.cisco.com__104Y2" from="pubsub.finesse1.dcloud.cisco.com">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="/finesse/api/User/1072/Dialogs">
<item id="460c2d27-c914-4c24-a95f-edf9f8df45c21535">
<notification xmlns="http://jabber.org/protocol/pubsub">
<Update>
<data>
<dialogs>
<Dialog>
<associatedDialogUri></associatedDialogUri>
<fromAddress>1071</fromAddress>
<id>18639330</id>
<mediaProperties>
<DNIS>1072</DNIS>
<callType>AGENT_INSIDE</callType>
<dialedNumber>1072</dialedNumber>
<outboundClassification></outboundClassification>
<callvariables>
<CallVariable>
<name>callVariable1</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable2</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable3</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable4</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable5</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable6</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable7</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable8</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable9</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable10</name>
<value></value>
</CallVariable>
</callvariables>
</mediaProperties>
<mediaType>Voice</mediaType>
<participants>
<Participant>
<actions>
<action>ANSWER</action>
</actions>
<mediaAddress>1072</mediaAddress>
<mediaAddressType>AGENT_DEVICE</mediaAddressType>
<startTime>2017-09-15T19:23:36.872Z</startTime> …Run Code Online (Sandbox Code Playgroud) 试图了解如何使用 Task.Delay 我一直在做一系列简单的实验,我发现了以下内容。
首先我这样做了
static void Main(string[] args)
{
Console.WriteLine("Start");
Task.Run(async () => {
Stopwatch sw = Stopwatch.StartNew();
await Task.Delay(2000);
// for(int i=0;i<1000;i++)
// await Task.Delay(2);
sw.Stop();
Console.WriteLine("Delay of {0}", sw.ElapsedMilliseconds);
//return sw.ElapsedMilliseconds;
});
Console.WriteLine("End of everything:");
Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)
结果正如预期的那样延迟了 2 秒多一点。到目前为止,一切都很好!然后我注释了延迟线并取消注释了 for 循环。1000 次 2 毫秒必须给出 2 秒,对吗?错误的!这次用了15秒。
我稍后会对此发表评论,但只是为了进行比较,我这样做了。
static void Main(string[] args)
{
Console.WriteLine("Start");
Stopwatch sw = Stopwatch.StartNew();
for (int i = 0; i < 1000; i++)
Thread.Sleep(2);
// Thread.Sleep(2000);
sw.Stop();
Console.WriteLine("Delay of {0}", sw.ElapsedMilliseconds);
Console.WriteLine("End");
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我得到了更精确的 …
我正在使用C#windows窗体并遇到了这个问题
我有两种形式,在第一种形式用户输入用户名和按下按钮.Button调用一个在数据库中保存用户名的函数.
private void btn_Click(object sender, EventArgs e)
{
Database db = new Database();
db.SaveUsername(txtUsername.Text);
new Form2().Show();
}
Run Code Online (Sandbox Code Playgroud)
这个SaveUsername()函数是在单独的类中
class Database
{
public void SaveUsername(string username)
{
Connect(); //Connection to database
//Some lines to save username in database
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是当用户点击进入它需要一点时间打开Form2所以我希望新的表单应该出现并且SaveUsername()功能在后台运行而无需用户等待它完成.怎么做?
尽管我用谷歌搜索了一段时间,但我找不到服务器端Blazor的任何Model-View-XYZ框架实现,即Razor组件(XYZ代表以下任何一种:Controller,Presenter,ViewModel)。
如果有人知道这样的实现,无论它处于开发的哪个阶段,请告诉我。非常感谢。
编辑:问题是,是否有人遇到或参与了这种框架的开发。
这个问题非常简单 -有人在Internet上遇到过一些有关针对Razor组件(又称为服务器端Blazor)的框架的信息,因为到目前为止我还没有。
经过大量探索后,我们还没有 blazor 组件秒表。我需要在 blazor 页面中显示经过的时间下面是我的代码,我们可以使用开始和停止按钮计算经过的时间我有点困惑如何在 blazor 页面中调用和显示经过的时间。有什么建议吗?
@using System.Diagnostics;
<p> <button @onclick=@Start>Start</button></p>
<p> <button @onclick=@Stop>Stop</button></p>
@code
{
protected override void OnInitialized()
{
base.OnInitialized();
Stopwatch sw = new Stopwatch();
TimeSpan tt1 = TimeSpan.Zero;
}
private double elapsedtime;
private DateTime startTime;
private DateTime stopTime;
private bool running = false;
public void Start()
{
this.startTime = DateTime.Now;
this.running = true;
}
public void Stop()
{
this.stopTime = DateTime.Now;
this.running = false;
}
public double ElapsedTimeSecs()
{
TimeSpan interval;
if (running)
interval = DateTime.Now …Run Code Online (Sandbox Code Playgroud) 启动了一个新的 Blazor WebAssembly 项目(Windows 10,Visual Studio 2019),尝试从服务器端通过 HttpClient 获取一个简单的列表。
错误:
00755c3a:0xa3a0 Uncaught (in promise) RuntimeError: memory access out of bounds
at malloc (<anonymous>:wasm-function[359]:0xa3a0)
at monoeg_malloc (<anonymous>:wasm-function[161]:0x3c71)
at stack_frag_new (<anonymous>:wasm-function[2019]:0x59758)
at add_frag (<anonymous>:wasm-function[1430]:0x3ccf2)
at interp_exec_method (<anonymous>:wasm-function[1120]:0x2f609)
at interp_runtime_invoke (<anonymous>:wasm-function[5655]:0xf7391)
at mono_jit_runtime_invoke (<anonymous>:wasm-function[5109]:0xddb3d)
at do_runtime_invoke (<anonymous>:wasm-function[1410]:0x3ba85)
at mono_runtime_try_invoke (<anonymous>:wasm-function[418]:0xcfdb)
at mono_runtime_invoke (<anonymous>:wasm-function[1610]:0x44b39)
Run Code Online (Sandbox Code Playgroud)
服务器端(正确返回):
[HttpGet]
public async Task<IEnumerable<UserDetailsRM>> Get()
{
var users = await UserService.GetUsers();
return users;
}
Run Code Online (Sandbox Code Playgroud)
客户端:尽管得到了结果,但不渲染任何东西。
<div class="userListWrapper">
@if (Users != null)
{
<table class="table table-borderless" style="font-size:12px; font-family:arial; height:
500px; …Run Code Online (Sandbox Code Playgroud) 我已经在这个程序上工作了大约一个月了,尝试了一切。无论我做什么,我的程序都会闪烁,即使在其他机器上也是如此。它只是一个背景、一个图像和一个矩形。没有什么大的或昂贵的。然而它仍然闪烁。我试过将 DoubleBuffered 设置为 true,我试过覆盖 CreateParams(它使我的窗口变黑),我试过使用反射的方法,我试过 SetStyle 来设置 DoubleBuffer、OptimizedDoubleBuffer、UserPaint、AllPaintingInWmPain 和 Opaque当设置为 true 时,他们都没有做任何事情。我已经在 google 和 stackoverflow 上搜索了答案,但没有一个起作用。我无法理解我做错了什么。我添加了代码、exe、编译脚本和图像的 zip。我和其他人的计算机上发生的事情就是 gif 上的内容。该程序每秒更新 4 次,足以绘制背景、图像和正方形的时间,但它仍然闪烁。请我需要帮助。
主文件:
using System;
using System.Threading;
using System.Windows.Forms;
public class main{
public static void Main(string[] args){
Console.WriteLine("START");
Engine.Init();
while(true){
Engine.MainDraw();
Application.DoEvents();
Thread.Sleep(250);
}
Console.WriteLine("END");
}
}
Run Code Online (Sandbox Code Playgroud)
引擎.cs:
using System;
using System.IO;
using System.Windows;
using System.Windows.Forms;
using System.Drawing;
public class Engine : Form{
public static Engine EngineForm = new Engine();
public static Graphics g;
/*
protected override CreateParams CreateParams{
get{
CreateParams …Run Code Online (Sandbox Code Playgroud) enum Answer : int { Yes = 1, No = 2 }
Answer answer = (Answer)100;
Run Code Online (Sandbox Code Playgroud)
它抛出,但我不想要它.怎么样?
我的表格有超过200个控件!加载表单并绑定控件大约需要7秒钟.
我用一些性能分析器跟踪了应用程序,但除了构造函数之外,我没有找到任何带有HOT标志的东西.
我想知道是否可以像backgroundWorker(多线程)一样调用InitializeComponent方法!
我想使用MessageBox来显示是/否问题,但它不起作用.如果他们是打开对话框的任何替代方案,请告诉我.
也许这是一个代码隐藏文件的事实有所不同?