using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
webBrowser1.Navigate("http://habrahabr.ru");
Thread t = new Thread(clicks);
t.Start();
}
public void clicks()
{
Thread.Sleep(5000);
//Клик по ссылке "правила"
this.Invoke(new ClickIt( clickOnTheLink),new object[] { webBrowser1, "Хабрахабр"});
Thread.Sleep(5000);
//Клик по ссылке "о сайте"
this.Invoke(new ClickIt(clickOnTheLink), new object[] { webBrowser1, "Тостер" });
}
private delegate void ClickIt(WebBrowser webBrowser, String s);
//Клик по ссылке с текстом
public void clickOnTheLink(WebBrowser webBrowser, String s)
{
HtmlElementCollection elements = webBrowser.Document.GetElementsByTagName("a");
Console.Beep();
foreach (HtmlElement a in elements)
if (a.InnerText == s)
a.InvokeMember("click");
}
}
}
class Program
{
static void Main(string[] args)
{
new TestClass();
Console.ReadLine();
}
}
class TestClass
{
public delegate void SampleEventHandler();
event SampleEventHandler onCreate;
public TestClass()
{
onCreate += delegate { Console.Write("Hello "); };
onCreate += () => { Console.Write("World "); };
onCreate();
}
}
void M(int i)
{
//какой то код
}
void M(int i,string s)
{
//какой то код
}
void M(int i,string s, char c)
{
//какой то код
}
Configure a service to start with the WinDbg debugger attached
You can use this method to debug services if you want to troubleshoot service-startup-related problems.
Configure the "Image File Execution" options. To do this, use one of the following methods:
Method 1: Use the Global Flags Editor (gflags.exe)
Start Windows Explorer.
Locate the gflags.exe file on your computer.
Note The gflags.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows.
Run the gflags.exe file to start the Global Flags Editor.
In the Image File Name text box, type the image name of the process that hosts the service that you want to debug. For example, if you want to debug a service that is hosted by a process that has MyService.exe as the image name, type MyService.exe.
Under Destination, click to select the Image File Options option.
Under Image Debugger Options, click to select the Debugger check box.
In the Debugger text box, type the full path of the debugger that you want to use. For example, if you want to use the WinDbg debugger to debug a service, you can type a full path that is similar to the following: C:\Program Files\Debugging Tools for Windows\windbg.exe
Click Apply, and then click OK to quit the Global Flags Editor.
Method 2: Use Registry Editor
Click Start, and then click Run. The Run dialog box appears.
In the Open box, type regedit, and then click OK to start Registry Editor.
Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows
In Registry Editor, locate, and then right-click the following registry subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
Point to New, and then click Key. In the left pane of Registry Editor, notice that New Key #1 (the name of a new registry subkey) is selected for editing.
Type ImageName to replace New Key #1, and then press ENTER.
Note ImageName is a placeholder for the image name of the process that hosts the service that you want to debug. For example, if you want to debug a service that is hosted by a process that has MyService.exe as the image name, type MyService.exe.
Right-click the registry subkey that you created in step e.
Point to New, and then click String Value. In the right pane of Registry Editor, notice that New Value #1, the name of a new registry entry, is selected for editing.
Replace New Value #1 with Debugger, and then press ENTER.
Right-click the Debugger registry entry that you created in step h, and then click Modify. The Edit String dialog box appears.
In the Value data text box, type DebuggerPath, and then click OK.
Note DebuggerPath is a placeholder for the full path of the debugger that you want to use. For example, if you want to use the WinDbg debugger to debug a service, you can type a full path that is similar to the following:
C:\Progra~1\Debugg~1\windbg.exe
<Image Width="22"
Height="22"
Margin="5"
>
<Image.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem}}" Value="true">
<Setter Property="Image.Source" Value="../Images/play2.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem}}" Value="false">
<Setter Property="Image.Source" Value="../Images/play.png"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
public class CurrentContext
{
private CurrentContext()
{
}
private static Lazy<CurrentContext> instance = new Lazy<CurrentContext>(() => new CurrentContext());
public static CurrentContext Instance
{
get { return instance.Value; }
}
public string Text {get;set;}
}
CurrentContext.Instance.Text="тест";