小编Hit*_*esh的帖子

线程中加入和等待的区别

Join :阻塞调用线程直到线程终止

await : 暂停方法的执行,直到等待的任务完成

加入和等待之间的其他区别是什么。

当我们可以使用 join 以及何时可以使用 await 时,有人可以帮助我吗?

谢谢,HItesh

c# asp.net multithreading thread-safety

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

验证hh:mm:ss

我是C#.net的新手.我想要一个仅采用hh:mm:ss格式的文本框验证.下面是我的代码和它的wroking.它给出的输出为真23:45:45(仅示例),对于-23:45:45也是如此(仅示例).现在我希望验证返回false为-23:45:45(仅示例),因为它是负时间.我的运行代码在负时间内不起作用.

          IsTrue = ValidateTime(txtTime.Text);
            if (!IsTrue)
            {

                strErrorMsg += "\nPlease insert valid alpha time in hh:mm:ss formats";
                isValidate = false;
            }

  public bool ValidateTime(string time)
    {
        try
        {
            Regex regExp = new Regex(@"(([0-1][0-9])|([2][0-3])):([0-5][0-9]):([0-5][0-9])");

            return regExp.IsMatch(time);
        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# time

2
推荐指数
2
解决办法
3617
查看次数

Angular 2 - 如何自动将对象值绑定到与Form控件相关的值?

我正在使用model driven forms,我正在寻找一种更好的方法将数据绑定到相关的,formControlName因为我的表单上有超过25个字段,我不想为所有字段编写代码,因为我已经写了对于下面.

模板:

<input type="text"
       class="form-control"
       formControlName="firstName"
       name="firstName"
       placeholder="First Name"
       required>
Run Code Online (Sandbox Code Playgroud)

组件:

this.refferalService.getReferringDataEdit(id).subscribe(
  result => {
    this.referringData = result.responseObject;
    this.refferalForm.patchValue({ 
      firstName: this.referringData.firstName 
    })
  }
)
Run Code Online (Sandbox Code Playgroud)

有没有办法"自动"?

angular2-forms angular2-template angular2-formbuilder angular

2
推荐指数
2
解决办法
2万
查看次数

如何在 Angular 7 中使用 Iframe

我使用 Iframe 通过以下方法在 HTML 中设置外部 URL:

方法一:

 <iframe [src]="sanitizer.bypassSecurityTrustResourceUrl(srcUrl)" height="600" width="1000"></iframe>
Run Code Online (Sandbox Code Playgroud)

方法 2:在此方法中,我还使用How to set <iframe src="...">创建了一个安全 PIPE,而不导致 `unsafe value` 异常?

 <iframe width="100%" height="300" [src]="srcUrl | safe"></iframe>
Run Code Online (Sandbox Code Playgroud)

方法三:

 <iframe #iframe height="600" width="1000"></iframe> 
  @ViewChild('iframe') iframe: ElementRef;
ngAfterViewInit() {
    this.iframe.nativeElement.setAttribute('src', this.srcUrl);
}
Run Code Online (Sandbox Code Playgroud)

但没有一个对我有用。我收到以下错误:

拒绝在框架中显示 '',因为祖先违反了以下内容安全策略指令:“frame-ancestors 'self' ”。

请在以下链接找到我的代码:

https://stackblitz.com/edit/angular-irwasj?file=src%2Fapp%2Fapp.component.html 任何人都可以帮忙吗?

angular

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

确定SQL中的列中是否有字符串可用

我有一个包含字段ID,名称和SubjectID的表.

其中SubjectID具有许多带逗号分隔符的值,例如.1,5,6,8

现在,如果传递参数5,那么我想找到所有在SubjectID中有5的行.

我使用了findstring,但它不起作用.

那么我怎样才能在Sql server 2008中实现这一点.

sql sql-server select sql-server-2008

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

在Angular 2中单击按钮时更新列表项的值

我有一个按钮btnAddUpdate,一个文本框和一个html文件中带有编辑按钮btnEdit的列表.当我单击btnAdd时,它会将一个文本框值插入到列表中,当单击btnEdit时,它将在文本框中显示所选值,现在我想在列表中更新该值.

以下是我的组件代码:

    import { Component } from '@angular/core';
    import {Hero} from './hero';   

    @Component({
      selector: 'my-Home',
       templateUrl: 'app/Home/home.component.html',
    })
    export class HomeComponent  {  

       title = 'Tour of Heroes';
       newH : Hero;
       heroes = [new Hero(1, 'Windstorm'), new Hero(13, 'Bombasto'),new Hero(15, 'Magneta'), new Hero(20, 'Tornado')];


// If not in list please add else Update list value.
      addHero(newHero:string) {
         this.title ="Button Clicked";
          if (newHero) {    
          let hero =  new Hero(14,newHero);   
          this.heroes.push(hero);
         }
      } 


       selectedHero = '';
    onEdit(hero: Hero) {   
    this.selectedHero = hero.name;

     } …
Run Code Online (Sandbox Code Playgroud)

typescript angular

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