小编Gra*_*ta1的帖子

带有选择下拉菜单的Blazor onchange事件

因此,当选择下拉列表值更改时,我一直试图获得一个简单的onchange进行触发。像这样:

<select class="form-control d-flex" onchange="(dostuff())">
    @foreach (var template in templatestate.templates)
    {
        <option value=@template.Name>@template.Name</option>
    }
</select>
Run Code Online (Sandbox Code Playgroud)

该方法被称为:

void dostuff()
{
   Console.WriteLine("first spot is firing");
    _template = templatestate.templates.FirstOrDefault(x => x.Name == 
    _template.Name);
    Console.WriteLine("second spot is firing");
}
Run Code Online (Sandbox Code Playgroud)

无论如何尝试重新定向,我得到的结果都是浏览器中的此错误。

Uncaught Error: System.ArgumentException: There is no event handler with ID 0
Run Code Online (Sandbox Code Playgroud)

有什么明显的关键我想念吗?因为我有一个按钮onclick事件,它在同一页面上也可以正常工作。

c# asp.net-core blazor

11
推荐指数
3
解决办法
7891
查看次数

你如何修复陷入困境的Thread Join()

我是多线程的新手,我只是尝试使用线程打印14000大小的字符串Arraylist来实践练习.我不是在考虑这个问题的效率,也不考虑有用性; 我只是想了解线程概念.

我的输出非常错误,我尝试了各种同步和其他失败的尝试.我现在遇到了一个名为join的工具,但是我的程序没有退出并继续运行.我调试了代码,程序只是卡在第一个线程连接上,我想不出任何理由或解决方案来解决问题.

我解决问题的方法是创建4个线程来分割打印任务.然后我会等到所有线程都完成并在关闭输出文件之前使用连接权限.

public class Threadprinting implements Runnable{
private static List<String> list;
private Thread T1,T2,T3,T4;
public void printinput(List<String> store){
    list=new ArrayList<String>(store);
    Threadprinting threadprinting=new Threadprinting();
    Threadprinting.generatethreads();   
}

public void generatethreads() {
    T1=new Thread(this,"t1");
    T1.start();
    T2=new Thread(this,"t2");
    T2.start();
    T3=new Thread(this,"t3");
    T3.start();
    T4=new Thread(this,"t4");
    T4.start();
}

public void run(){
    try {               
        PrintWriter out = new PrintWriter(new FileWriter("Output.txt"));
        switch (Thread.currentThread().getName()) {
            case "t1":
                System.out.println("Thread "+ Thread.currentThread().getName() + " is running");
                for (int i = 0; i < list.size() / 4; i++) {
                    out.println((list.get(i))); …
Run Code Online (Sandbox Code Playgroud)

java multithreading

1
推荐指数
1
解决办法
1294
查看次数

标签 统计

asp.net-core ×1

blazor ×1

c# ×1

java ×1

multithreading ×1